Menu

Tree [71a2a4] master /
 History

HTTPS access


File Date Author Commit
 App 2021-09-18 Daniel Pfeiffer Daniel Pfeiffer [a16d9d] v0.61, fix regression in keydiff fallback. Imp...
 pod 2022-05-08 Daniel Pfeiffer Daniel Pfeiffer [71a2a4] Add _ to ambiguous uppercase HTML ids. Many do...
 t 2022-05-02 Daniel Pfeiffer Daniel Pfeiffer [1c6da7] Work around new signature feature incompatibili...
 INSTALL 2022-03-09 Daniel Pfeiffer Daniel Pfeiffer [e48e97] Generalize quoted highlighting, and make pl bol...
 MANIFEST 2022-05-02 Daniel Pfeiffer Daniel Pfeiffer [1c6da7] Work around new signature feature incompatibili...
 Makefile.PL 2022-01-06 Daniel Pfeiffer Daniel Pfeiffer [76d923] Add optional number to -o, improve examples, fi...
 README 2022-05-08 Daniel Pfeiffer Daniel Pfeiffer [71a2a4] Add _ to ambiguous uppercase HTML ids. Many do...
 pl 2022-05-08 Daniel Pfeiffer Daniel Pfeiffer [71a2a4] Add _ to ambiguous uppercase HTML ids. Many do...
 pl.cmd 2020-06-14 Daniel Pfeiffer Daniel Pfeiffer [504002] new

Read Me

pl - Perl One-Liner Magic Wand

Some tasks are too menial for a dedicated script, but still too cumbersome
even with the many neat one-liner options of "perl -E".  This small script
fills the gap: various one-letter commands & magic variables (with meaningful
aliases too) and more nifty loop options take Perl programming to the command
line.  Fully imports List::Util.  With no program on the command line, starts
a pl Shell.

How to "e(cho)" values, including from "@A(RGV)", with single "$q(uote)" &
double "$Q(uote)".  Same for hard-to-print values:

    pl 'echo "${quote}Perl$quote", "$Quote@ARGV$Quote"' one liner
    pl 'e "${q}Perl$q", "$Q@A$Q"' one liner

    pl 'echo \"Perl", \@ARGV, undef' one liner
    pl 'e \"Perl", \@A, undef' one liner

Loop over args, printing each with line ending.  And same, SHOUTING:

    pl -opl '' Perl one liner
    pl -opl '$_ = uc' Perl one liner

Print up to 3 matching lines, resetting count (and "$.") for each file:

    pl -rP3 '/Perl.*one.*liner/' file*

Count hits in magic statistics hash "%N(UMBER)":

    pl -n '++$NUMBER{$1} while /(Perl|one|liner)/g' file*
    pl -n '++$N{$1} while /(Perl|one|liner)/g' file*

Though they are sometimes slightly, sometimes quite a bit more complicated,
most Perl one-liners from the internet work, just by omitting "-e" or "-E".
Known minor differences are:

* don't "goto LINE", but "next LINE" is fine

* in a "-n" loop "last" is per file instead of behaving like "exit"

* using "pop", etc. to implicitly modify "@A(RGV)" works in "-B" begin code,
but not in your main program (which gets compiled to a function)

* shenanigans with unbalanced braces won't work