$ cat foo.pl #!/usr/bin/perl use strict; use warnings; use Getopt::Long; my %opts; GetOptions(\%opts, 'foo=s', 'v'); # '=s' modifier means foo needs argument, and it can be # any string (another modifier is '=i' for integer.) print "foo = $opts{foo}, verbose = $opts{v}\n"; $ perl foo.pl --foo=bar -v foo = bar, v = 1 $ ./foo.pl --for=bar -v foo = bar, v = 1