in reply to map question
next won't do very much for you outside of a loop. Using tools such as map with an implicit loop do not allow the use of next. However you can combine map and grep to achieve what you want:
use strict; use warnings; my @fields = ( 'abc abc1 abc2', 'abc abc1 abc3 abc5', 'abc2 abc3 abc5 abc7 abc9 abc10', 'abc1 abc2 abc3 abc4 abc5 abc6', ); print grep {length > 15} map {s/\s+//g; "$_\n"} @fields;
Prints:
abcabc1abc3abc5 abc2abc3abc5abc7abc9abc10 abc1abc2abc3abc4abc5abc6
with the further advantage that you don't have to maintain the same piece of code in multiple places.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: map question
by convenientstore (Pilgrim) on Jul 29, 2007 at 01:52 UTC | |
by GrandFather (Saint) on Jul 29, 2007 at 03:46 UTC |