my %Args; # Hash of arrays for arguments. my $SwitchName; # The current switch name foreach ( @values ) { if ( /^\-/ ) { $SwitchName = $_; else { push ( @{ $Args{ $SwitchName } }, $_ ); } }