use strict; use warnings; use Getopt::Long; use vars qw($opt_u $opt_h $opt_a $opt_l); &GetOptions('l=s','u','h','a') || exit 1; print "Option found: u\n" if ($opt_u); print "Option found: h\n" if ($opt_h); print "Option found: a\n" if ($opt_a); if ($opt_l) { print "Option found: l\n"; print " with value: $opt_l\n"; } else { print "You must specify -l\n"; exit 1; }