use Getopt::Long; #my $foo = 1; GetOptions ('foo=s', \$foo); print "foo: $foo\n" if $foo; print "Unprocessed by Getopt::Long\n" if $ARGV[0]; foreach (@ARGV) { print "$_\n"; }