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

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.

Replies are listed 'Best First'.
Re^4: IO::Handles ... any good?
by ikegami (Patriarch) on Mar 23, 2009 at 02:25 UTC

    -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