foreach
loop's implicit aliasing and localizing
can make for a powerful construct:foreach $e (@a, @b) { $e *= 3.14159 }
for (@lines) { chomp; s/fred/barney/g; tr[a-z][A-Z]; }
foreach $n (@square = @single) { $n **= 2 }
# trim whitespace in the scalar, the array, # and all the values in the hash foreach ($scalar, @array, @hash{keys %hash}) { s/^\s+//; s/\s+$//; }
Forward to Avoid Byte Processing
Back to Use $_ in Short Code
Up to index
Copyright © 1998, Tom Christiansen
All rights reserved.