News for hackers. Stuff that matters.
Re:Awk in 20 Minutes (2015) by AceJohnny2 on Friday May 01, 2020 @11:45PM (#23048962)
For my & others' reference (because I keep having to look it up, just like parent):

    perl -ne "print $_;"
'-n' will run the expression over each line of the input. This is the Awk-like mode.

    perl -pe "s/foo/bar/"
'-p' will run the expression over each line of input, and print out the (possibly modified) line. This is the Sed-like mode.

Slightly more info available in `man perlrun` or https://perldoc.perl.org/perlrun.html

Re:Awk in 20 Minutes (2015) by hf on Saturday May 02, 2020 @04:21AM (#23050283)
One particularly mnemonic collection of switches is 'plane':

    perl -plane 'my $script' 
which iterates over all files given on the command-line (or stdin) and

  + (p)rints every processed line back out
  + deals with (l)ine endings, in and out
  + (a)utosplits every line into @F
I am aware that -n and -p are mutually exclusive, but as -p overrides -n, it's seems simpler to just keep 'plane' in mind and remove the 'p' if necessary.