use Getopt::Long; my $debug = 0; # Optional parameters (removed from @ARGV) GetOptions( 'debug' => \$debug, ); # Positional parameters (left in @ARGV) my ($infile) = @ARGV;