Current Perl documentation can be found at perldoc.perl.org.
Here is our local, out-dated (pre-5.6) version:
Use for
/foreach
:
for (@lines) { s/foo/bar/; # change that word y/XZ/ZX/; # swap those letters }
Here's another; let's compute spherical volumes:
for (@volumes = @radii) { # @volumes has changed parts $_ **= 3; $_ *= (4/3) * 3.14159; # this will be constant folded }
If you want to do the same thing to modify the values of the hash, you may not use the values function, oddly enough. You need a slice:
for $orbit ( @orbits{keys %orbits} ) { ($orbit **= 3) *= (4/3) * 3.14159; }