in reply to Parsing @ARGV w/ Map Function
%setting = map {/^--(.*?)=/ => /=(.*)$/} @ARGV;
The first one is the only one I think works well.
It would also work just as well as:
my %setting = map /^--(.*?)=(.*)$/, @ARGV;
%file = map {$_ => (s/^([^=-]*)$/$1/)} @ARGV;
%switch = map {$_ => (s/^--([^=]*)$/$1/)} @ARGV;
The 2nd one had to go next since the 3rd messes up the arguments for future passes through @ARGV.
Any expression that modifies $_ also modifies @ARGV so both the 2nd and 3rd modify @ARGV. However, you don't have to modify $_ to get the results that you want:
my %file = map { $_ => /^([^=-]*)$/ ) } @ARGV; my %switch = map { $_ => /^--([^=]*)$/ } @ARGV;
|
|---|