It is possible, but using a while loop is better:
--my $raw = "foo=1 baR= red BOO = 5.6 Baz =3"; my %params = (); use Benchmark qw/cmpthese/; my $test = { 'map' => sub { %params = map { (lc($_) => $raw =~ /$_\s*=\s*(\S+)/ ) } $raw =~ /(\S+)\s*=/g; %params = (); }, 'while' => sub { $params{lc($1)} = $2 while $raw =~ /(\S+)\s*=\s*(\S+)/g; %params = (); } }; #no regexp initialisation in benchmark $_->() for values %$test; cmpthese( -4 , $test );
In reply to Re: lowercasing during a match?
by fruiture
in thread lowercasing during a match?
by mordibity
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |