Bart Lateur <bart.lateur@skynet.be> wrote: > #perl -i.bak > undef $/; #whole file at once > while(<>) { > s/\012|\015\012|\015/\n/g; > print; > } Better... #!perl -l000i.bak s/\012|\015\012|\015/\n/g; print; ....which is using the switches to their utmost extent (at least that extent on the Mac). -l000 is just another way of saying "undef $/;" can't do -p in this instance, because we're processing line endings specifically, and -p in the context of -l does chomp() on the input. Otherwise I'd be able to drop the explicit print(). #!perl -l000i.bak -e s/\012|\015\012|\015/\n/g;print Is how it would look if you could use -e, which you can't under the MacPerl app. BTW, this code converts newlines to the correct newline for YOUR system, regardless of what that system is. I'm not knocking you, Bart. It's good to lay out the logic the way you did, at least on the first iteration, so you (and perhaps the persons you're demonstrating the solution to as well) know what you're doing. After a while, though, when you see certain structures, you learn to substitute the equivalent switches. 'undef $/; while(<>)' together quickly transform into "-l000". In most cases, when the last statment in the while() loop is "print;", you can also add a '-p'. In this case, as explained above, you can't because of the way the switches affect each other. Plus, it really blows Unix folks away seeing us MacPerler's using the switches (remember, they're command-line things under Unix (along with the whole concept of the #!), and there's no command line on a Mac (so the Unix folks might mistakenly believe that ALL the switches are disabled in MacPerl ('cept for the ones who also USE MacPerl, of course)). #! switches are *emulated* in MacPerl, and only a few of them CAN'T be emulated. Brian McNett, Webmaster ************************************************************* Mycoinfo. The world's first mycology e-journal. http://www.mycoinfo.com/ ************************************************************* # ===== Want to unsubscribe from this list? # ===== Send mail with body "unsubscribe" to macperl-request@macperl.org