1. 14

Here’s part 2: https://www.perl.com/article/perl-one-liners-part-2/

  1.  

  2. 3

    I will say, even as a hardened Perl nerd and user since 4.036, some of these tasks I’d probably reach for awk first even though Perl subsumes (and was designed to subsume) most of its use cases.

    1. 1

      Yeah, I reach for sed or awk first too. Perl helps when I need more powerful regexp features and other built-in goodies.

    2. 3

      I find Perl especially useful for processing data separated by an empty line. By setting $/ to the empty string, “paragraph mode” is activated. You can do this on the command line by passing the -00 option:

      perl -00 -ne 'print if /something/'
      # prints paragraph if it has "something" in it