Perl Language Perl one-liners Execute some Perl code from command line

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

Simple one-liners may be specified as command line arguments to perl using the -e switch (think "execute"):

perl -e'print "Hello, World!\n"'

Due to Windows quoting rules you can't use single-quoted strings but have to use one of these variants:

perl -e"print qq(Hello, World!\n)"
perl -e"print \"Hello, World!\n\""

Note that to avoid breaking old code, only syntax available up to Perl 5.8.x can be used with -e. To use anything newer your perl version may support, use -E instead. E.g. to use say available from 5.10.0 on plus Unicode 6.0 from >=v5.14.0 (also uses -CO to make sure STDOUT prints UTF-8):

5.14.0
perl -CO -E'say "\N{PILE OF POO}"'


Got any Perl Language Question?