Just one small self-contained script extends "perl -E" with many bells &
whistles: Various one-letter commands & magic variables (with meaningful
aliases too) and more nifty loop options take Perl programming to the command
line. List::Util is fully imported. Unless you pass a program on the command
line, starts a simple Perl Shell.
How to "e(cho)" values, including from "@A(RGV)", with single "$q(uote)" &
double "$Q(uote)". Same for hard-to-print values:
pl 'e "${q}Perl$q", "$Q@A$Q"' one liner
pl 'e \"Perl", \@A, undef' one liner
Print up to 3 matching lines, resetting count (and "$.") for each file:
pl -rP3 '/Perl.*one.*liner/' file1 file2 file3
Loop over args, printing each with line ending. And same, shouting:
pl -opl '' Perl one liner
pl -opl '$_ = uc' Perl one liner
Count hits in magic statistics hash "%n(umber)":
pl -n '++$n{$1} while /(Perl|one|liner)/g' file1 file2 file3
Even though the point here is to make things even easier, most Perl one-liners
from the internet work, just by omitting "-e" or "-E". A few differences are:
don't "goto LINE", but "next LINE" is fine. In "-n" "last" goes straight to
the next file instead of being like "exit". And shenanigans with unbalanced
braces won't work.