in reply to Re: IO::Handles ... any good?
in thread IO::Handles ... any good?

Quite a bit beyond me but... wow, I will use as a shell alias - thanks.
Here's my effort at decoding your line :

perl <br> -i #edit in place .bak #but make a new file -p # read every line from default arg e # excecute code from command line ' #code for the default while loop $_ # default variable, each line of file . # and = # equal to " #start printing this literally \n #new line " #finish literal printing ' # end/start next loop

Replies are listed 'Best First'.
Re^3: IO::Handles ... any good?
by linuxer (Curate) on Mar 22, 2009 at 21:11 UTC
    perl -i # edit in place .bak # rename original file by appending .bak to filename; print to n +ew file with original name -p # use a while loop to read each file; print each line (is stored + in $_) which you have read (and modified) e # excecute code from command line ' # start of code to be executed (for the default while loop) $_ # default variable, each line of file .= # append the following to yourself ($_) and assign it to you "\n" # string to be appended ' # end of code

    $_ .= "\n"; is the shorter form of $_ = $_ . "\n";

    Check perlrun and look for the explanation for option -i. They have some examples there. -p should be explained in more details, too.

      -p should be explained in more details, too.

      -p is nicely explained using Deparse.
      >perl -MO=Deparse -pe"body()" LINE: while (defined($_ = <ARGV>)) { body(); } continue { die "-p destination: $!\n" unless print $_; } -e syntax OK