NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
GCDs in a regex (Score:1)
My most common ones are pretty simple. (Score:1)
perl -MSome::Module -e 0perl -E 'say foreach split ":", $ENV{PATH}' # Or other pathlike thing.ack --text -l '\bv1.2.3\b' | xargs perl -pi -e 's/\bv1\.2\.3\b/v1.2.4/g'Otherwise, it's mostly experiments; I prefer bash to a REPL.
MetaSyntactic (Score:2)
Or, if I need several alternatives to boring values like 'foo':
But usually I prefere the
donmartinthemeVarious one-liners from MNooning (Score:1)
Here are some Windows one-liners. On Linux, use single quotes and forward slashes.
Find the INC path that Perl sees when it starts up.
>perl -e "print qq[INC = @INC\n];"
INC = C:/Perl/site/lib C:/Perl/lib
Another way to find the INC path.
perl -wle "print for @INC"
C:/Perl/site/lib
C:/Perl/lib
Find out if a module is installed. If it is, no error messages will show.
>perl -e "use Tk"
Obtain the version of an installed module.
>perl -MTk -e "print \"$Tk::VERSION\n\"
804.0285
Eval (Score:2)
Still my favorite is:
It's a pure REPL. It evaluates every line from stdin and outputs whatever they evaluate to. It has many uses, but most of the time it's "just" a very powerful calculator.
The awk features are rather nice (Score:1)
I find I use -a rather alot for snippets like the following:
It's still useful for alternative delimiters. Pretending dpkg used tabs for delimiters, I'd add the parameter
It also find it's really helpful to got a proper handle on quoting whether in my shell or in perl. Often in a one-liner I'm using qq{} in perl to avoid messing with my shell's own use of ' or ". Occasionally I use bash's $'\t' syntax which lets me say things like
The cutest of them all (Score:1)
Here’s a replacement for cat(1):
perl -please somefile.txt