Perl (Scripting) - Running commands inline

by
Jeremy Canfield |
Updated: June 12 2024
| Perl (Scripting) articles
Almost always, Perl is run as a script. For example, example.pl has the following.
#!/usr/bin/perl
use strict;
use warnings;
print "Hello World\n";
Running this script should output Hello World.
~]# perl example.pl
Hello World
Sometimes, you may want (or need) to run Perl on the command line. The -e option can be used to "execute" Perl commands on the command line.
~]# /usr/bin/perl -e "use strict; use warnings; print 'Hello World\n';"
Hello World
Did you find this article helpful?
If so, consider buying me a coffee over at