The problem is that the expression $_->{key} => $_->{value} if($_->{key} =~/^a\d+/) will still return something if $_->{key} =~/^a\d+/ doesn't match. You should try it like this:
my %ret = map $_->{key} =~ /^a\d/ ? ( $_->{ key } => $_->{ value } ) : + (), @$data1;
In reply to Re: map with empty item
by jwkrahn
in thread map with empty item
by remiah
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |