use Getopt::Std; # declare the perl command line flags/options we want to allow my %opts; getopts('f:', \%opts); # test for the existence of the options on the command line. if ($opts{f}) { my $file = $opts{f}; print "$file\n"; }