Difference between revisions of "Perl"
From Organic Design wiki
(→See also: Quotemeta) |
(→See also: Reading and writing UTF-8 examples with IO::All) |
||
Line 37: | Line 37: | ||
*[http://perl.com/pub/1999/10/DBI.html Basic DBI tutorial] | *[http://perl.com/pub/1999/10/DBI.html Basic DBI tutorial] | ||
*[[Regular expressions]] and [http://perldoc.perl.org/functions/quotemeta.html Quotemeta] | *[[Regular expressions]] and [http://perldoc.perl.org/functions/quotemeta.html Quotemeta] | ||
+ | *[https://perl-begin.org/topics/files-and-directories/ Reading and writing UTF-8 examples with IO::All] | ||
[[Category:Programming languages]] | [[Category:Programming languages]] |
Revision as of 13:19, 7 January 2019
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