Next | Welcome to my ~/bin | 4 |
First, does everyone know about this?
@numbers = (1..4); for (@numbers) { $_ *= 2; } print "@numbers\n"; # prints 2 4 6 8
How about this?
($a, $b, $c, $d) = (1..4); for ($a, $b, $c, $d) { $_ *= 2; } print "$a $b $c $d\n"; # prints 2 4 6 8
How about this?
($a, $b, $c, $d) = qw(Why X-ray your zebra?); for ($a, $b, $c, $d) { s/[aeiouy]/*/g; } print "$a $b $c $d\n"; # prints Wh* X-r** ***r z*br*?
continued...
Next | Menu | Copyright © 2005 M. J. Dominus |