Switches in this variable are treated as if they were on every Perl command line. It is pretty because it is the most precise way to specify options for command line arguments I have ever seen. Simple Clients. Assuming you start Perl as follows: perl -s script.pl -foo -bar myfile.dat. and contains the string "perl". Command-line options (switches). The second standard trick to perl one-liners are the -n and -p flags. With this code snippet, you can define any number of options like a professional Perl developer in a professional way. A thorough knowledge of the command line switches will enable you to create short one-time programs to perform odd little tasks. In this article we'll look at some of the most useful of these. Perl has a wide range of command-line options or switches that you can use. Leading garbage + will be discarded until the first line that starts with #! Example 1: A typical Perl command line args example. Always either use this flag, or else define use warnings; in your program. Step1 Create a script welcome.pl in your system. This can be very useful in filtering text files. Perl will remove anything that look like options (‘ … Perl Command-Line Options perl.com. In this way Perl can replace grep | sed in a single one-liner.. For example: perl -ne 'print "$1\n" if /Messages read: (\d+)/'