That generates an undef when the match fails, and shallow-copies the arrayref $d[$mapkey] when the match succeeds. Sounds like you want something more like (untested):[@{$d[$mapkey]}] if $d[$mapkey]->[1] =~ /$a[$_]/
to provide an empty list when the match fails. Using ?: in a map is a common idiom.$d[$mapkey]->[1] =~ /$a[$_]/ ? [@{$d[$mapkey]}] : ()
In reply to Re: map weirdness
by ysth
in thread map weirdness
by insaniac
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |