use strict; use warnings; my @ARGV = qw(-infile data_in.bin -outfile data_out.bin); my %args; for ( 0 .. $#ARGV / 2 ) { my $switch = shift(@ARGV); my $value = shift(@ARGV); $args{$switch} = $value; } print "Infile: $args{-infile}\n", "Outfile: $args{-outfile}" if ( exists $args{-infile} && exists $args{-outfile} );