* added a map() example, but left the foreach intact
Index: perlfaq4.pod
===================================================================
RCS file: /cvs/public/perlfaq/perlfaq4.pod,v
retrieving revision 1.25
diff -u -d -r1.25 perlfaq4.pod
--- perlfaq4.pod 30 May 2002 07:04:25 -0000 1.25
+++ perlfaq4.pod 10 Jul 2002 08:42:49 -0000
@@ -1398,6 +1398,11 @@
$_ **= 3;
$_ *= (4/3) * 3.14159; # this will be constant folded
}
+
+which can also be done with map() which is made to transform
+one list into another:
+
+ @volumes = map {$_ ** 3 * (4/3) * 3.14159} @radii;
If you want to do the same thing to modify the values of the
hash, you can use the C<values> function. As of Perl 5.6