in reply to SIMPLE way to write these?
Any C-style for loop:
for (INIT; COND; POST) { BODY; }
Can always be rewritten as a while loop like this:
INIT; while (COND) { BODY; POST; }
So your loop can be written as:
$j=1; while ($j<=10) { print "$j\n"; $j++; }
However, in Perl there are more idiomatic ways of writing it. For example:
print "$_\n" for 1..10;
Or, if you've got a recent version of Perl, and enable the "say" feature:
say for 1..10;
|
|---|