in reply to map weirdness
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]}] : ()
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: map weirdness
by insaniac (Friar) on Dec 13, 2004 at 12:57 UTC |