Can be rewritten as:map { MAPCLAUSE } grep { GREPLCAUSE }
For instance, if you want a list of the squares of the first five odd numbers, either of these will work.map { GREPCLAUSE ? MAPCLAUSE : () }
@odds_squared = map { $_**2 } grep { $_%2 } 1..10; @odds_squared = map { $_%2 ? $_**2 : () } 1..10; Result: 1 9 25 49 81
-Blake
In reply to Re2: Idioms considered harmful
by blakem
in thread Idioms considered harmful
by rinceWind
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |