in reply to back iffing with for?

As ysth pointed out, you need to use the non c-style for loop. In addition, you have to initialize $product to 1 each time through the loop. And if you want to make your program more Perl-like, you should always use warnings; (as well as strict) - perl would have complained about the uninitialized $product.

So, this works for me:
use strict; use warnings; my ($product,@values); @values = (7,38,44,2,0); foreach my $number (@values) { unless($number == 0) { print $number; # $product *= $number for(1 .. $number); $product = 1; $product *= $_ for(1 .. $number); print " Factorial is $product\n"; } else { print "0 Factorial is 1\n"; } }