Perl
From Organic Design wiki
Perl one liners
If you type;
perl --help
on the command line, Perl will provide details on its usage and command line switches. The switches we are interested in are
-d[:debugger] run program under debugger -e program one line of program (several -e's allowed, omit programfile) -n assume 'while (<>) { ... }' loop around program
Using -e switch
# Unix/Linux
perl -e 'print "It matches\n" if "Hello World" =~ /World/;'
# Windows
perl -e "print \"It matches\n\" if "Hello World" =~ /World/;"
- See string literals for details on differences between single and double quotes.
Using -de switch
To initiate the debugger for a one line program type;
perl -de 42
Now type 'h' to obtain for help commands used within the debugger. Commands useful for one liners in the debugger are;
- 'x' to eval an expression in list context, and print the result.
- 'q' to quit