in reply to "foreach" is to "next" as "map" is to ???
So return an empty list to produce a no-op in map's output. If you don't want the whole thing wrapped in a conditional like this, you can also use return () somewhere in the block as a guard condition in place of next, but you have to mess with the syntax a little:my @results = map { m/good stuff/ ? do { ... } : () } @array;
Note the sub keyword, and the comma after the sub. All in all, it's probably clearest to tack on a grep before the map:my @results = map sub { return () unless m/good stuff/; ... }, @array;
my @results = map { ... } grep { m/good stuff/ } @array;
blokhead
|
|---|