in reply to Yet another one-liner

Why use -n and not -p here?:

perl -i.bak -pe 'print "\n" if($.==1)'

or in the Perl Golf spirit:

perl -i.bak -pe 's/^/\n/ if($.==1)'

Update:Darn! fundflow is right! So let's try:

 perl -i.bak -pe 's/^/\n/ if(!$a); $a= !eof'

This one should work fine

Replies are listed 'Best First'.
Re: Re: Yet another one-liner
by fundflow (Chaplain) on Jan 12, 2001 at 00:58 UTC
    this doesn't work as $. isn't reset after each file:
    perl -pe 'print "$. "' file1 file2 1 2 1 3 2 4 3 5 1 6 2 7 3 [
    Is this a bug? I'm using v. 5.6.0

      That is why you need the explicit close that the original poster included. Good catch!

              - tye (but my friends call me "Tye")