in reply to SIMPLE way to write these?
for my $i (1 .. 10) { print "$i\n"; }
Or, even, something like
use feature qw{ say }; say for 1 .. 10;
With a while loop, you just have to initialize a counter, and then check its value against the final value in the loop condition:
my $i = 1; while (10 >= $i) { print $i++, "\n"; }
The factorial is left as an exercise for the reader.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: SIMPLE way to write these?
by Anonymous Monk on Feb 04, 2014 at 14:13 UTC | |
by choroba (Cardinal) on Feb 04, 2014 at 14:24 UTC | |
by Anonymous Monk on Feb 04, 2014 at 14:36 UTC | |
by GotToBTru (Prior) on Feb 04, 2014 at 15:04 UTC | |
by Jenda (Abbot) on Feb 05, 2014 at 09:59 UTC |