perlrun modes
perlrun modes
Modes
-n
Assumes the following structure
while(<>) {
// code goes here
}
Example:
cat test.txt | perl -ne 'chomp;print $_ . " ";'
-p
Assumes the following structure and make it similar to sed
while(<>) {
// code goes here
} continue {
print or die "-p destination: $!\n";
}
Example:
cat test.txt | perl -pe 'chomp;'
-u
Dumps code