Do you know where your variables are? | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
You can exit map() with a return, like this: sub{ map { print ; return if 5 >= $_ ; $_ } @arr; }->(); but in doing so, now you can no longer store the map-derived values to a named array, you will have to push them: # This is no good, values are not stored in @early: sub{ @early = map { print ; return if 5 >= $_ ; $_ } 3..9; }->(); # This is how to store values into @early : sub{ map { print ; return if $_ == 5 ; push @early, $_ } 3..9; }->(); Here is the full snipplet:
In reply to Re: Ways to control a map() operation
by ioannis
|
|