1. Commandline

To run Perl programs on the command line, the first option you need is the switch -e which ensures code to be executed by the compiler (yes, this switch will always be specified for every perl one liner).

For example, to print "Hello World" at the terminal, just type the following at the command line:

$ perl -e 'print(\"Hello World\");'
Notice that the parentheses and semicolon can be left out. But I do not recommend it.

To calculate the sum of two digits, type

$ perl -e '$result = sqrt(144) + sqrt(196); print($result);'

or shorter

$ perl -e 'print(sqrt(144) + sqrt(196));'

To add automatically a newline character use the -l switch:

$ perl -l -e '$result = sqrt(144) + sqrt(196); print($result);'

Any Perl one-liner can be converted into a full script via the B:Deparser compiler, which is a core Perl module (so nothing to install).