in reply to back iffing with for?

The c-style for loop (for (a;b;c)) doesn't work as a statement modifier, only the for (@list) kind of for:
$product *= $_ for 1..$number;
(update: corrected per ikegami) where .. is used to produce a list.

See http://search.cpan.org/perldoc/perlsyn#Statement_Modifiers (noting that foreach and for are synonymous).

Replies are listed 'Best First'.
Re^2: back iffing with for?
by ikegami (Patriarch) on Apr 06, 2005 at 04:26 UTC

    Don't you mean
    $product *= $_ for 1..$number;
    rather than
    $product *= $number for 1..$number;

    And in this case, you can start at 2:
    $product *= $_ for 2..$number;