in reply to Re: Assign result of map to scalar variable
in thread Assign result of map to scalar variable

... map will output a value for each input value it receives. If there is a match, $1 is returned. If the match fails, the value of the last expression evaluated

Not if you return an empty list (). The usual idiom is this:

my @map_some = map { /foo(bar)baz/ ? $1 : () } @all;

(However, I'm apparently having a Copy/Paste-challenged day, so if you read my node within the first few minutes, it still would have had the OP's if conditional rather than the one I tested.)

Replies are listed 'Best First'.
Re^3: Assign result of map to scalar variable
by AnomalousMonk (Archbishop) on Jul 18, 2013 at 20:37 UTC
    ... if you read my node within the first few minutes ...

    We may be playing update tag. I updated my original reply here (so quickly I thought no one would notice) to preface "... map will output a value..." with the qualification "As given in the OPed code, ".