In this article we'll look at some of the most useful of these. Command-line options (switches). The Perl script is free to interpret the command line arguments the way it likes. In Chapter 7, Graphical Examples with Perl/Tk, we have some additional examples with a graphical interface using the Tk extension to Perl. Here is a beautiful Perl code example that process command line arguments with specified options. 17 - Command-line Options. H ow do I read or display command-line arguments with Perl? If a directory name is specifie + d, Perl will switch to that directory before running the program. Perl uses a special command line option ‘-s’ to facilitate the option handling for scripts. Example 1: A typical Perl command line args example. and contains the string "perl". We need two command line arguments as user's first and last name. In this way Perl can replace grep | sed in a single one-liner.. For example: perl -ne 'print "$1\n" if /Messages read: (\d+)/'