in reply to map2 {} grep2 {} ...
%h_numbers = map {looks_like_number($h{$_}) ? ($_, $h{$_}) : ()} keys +%h; # Or %h_numbers = map {($_, $h{$_})} grep {looks_like_number($h{$_})} keys +%h; %h_prefixed = map {($_, "p".$h{$_})} keys %h; # Or %h_prefixed = %h; $_ = "p$_" for values %h_prefixed; # Both solutions below destroy @a; but you can make a copy first. while(my($x,$y) = splice @a, 0, 2) {push @a_hashed, {$x, $y}} # Or push @a_hashed, {shift @a, shift @a} while @a;
|
---|