in reply to back iffing with for?

Here's how I would recast your snippet:

use strict; my @values = ( 7, 38, 44, 2, 0 ); for my $number (@values) { my $product = 1; $product *= $_ for 2 .. $number; print "$number Factorial is $product\n"; }
I moved $product to inside the loop, since it's generally a good idea to limit the scope of variables as much as possible. This precaution is helpful only if running under strict, which I added. (With the exception of the fixing the foreach(;;) syntactic error that ysth already pointed out, the use strict line is probably the most important improvement in the version above.) Also note that the internal for loop does not execute if $number < 2.

Update: Fixed the missing use strict, and added explanatory remarks.

the lowliest monk