in reply to Ways to control a map() operation

map and grep aren't flow control operations. They process each element of a list and return a list.

Instead of exiting a map or grep block, return an empty list. (You might also use a function from List::Utils instead, such as first().)

Replies are listed 'Best First'.
Re^2: Ways to control a map() operation
by Aristotle (Chancellor) on Jul 16, 2006 at 12:11 UTC

    List::Util::first gives you something akin to last, but it’s only a replacement for some uses of grep, and there’s nothing to give you something like next.

    Makeshifts last the longest.