use strict; use warnings; use Data::Dumper; my $i=0; my %hARGV = map { if (/^--(\w+)=(\w+)$/) { # option => value $1 => $2; } elsif (/^--(\w+)$/) { # flag => 1 $1 => 1 } elsif (m{^[\w/]}) { # filename => fileorder $_ => $i++; } else { # bad argument - add nothing to the result hash warn "Invalid option: <$_> - options must begin with " ."-- or be a legal file name"; (); } } @ARGV; print Dumper(\%hARGV);