in reply to Re^2: SIMPLE way to write these?
in thread SIMPLE way to write these?

Ahem, just replace 1 (that is not followed by 0) with $number1; and similarly, replace 10 with $number2.
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^4: SIMPLE way to write these?
by Anonymous Monk on Feb 04, 2014 at 14:36 UTC
    Like this?
    my $i = $number1; while ($number2 >= $number1) { print $i++, "\n"; }
    It goes into an infinite loop...I am clearly making a silly mistake here...

      You are comparing $number2 and $number1 in your while; neither ever changes. That's why you get an infinite loop. Here is a solution that preserves the value in $number1.

      my $number1 = 1; my $number2 = 10; my $i = $number1; while ($number2 >= $i) { print $i++,"\n"; }

        I think most would write this using the three argument for() statement:

        my $number1 = 1; my $number2 = 10; for (my $i = $number1; $i <= $number2; $i++) { print "$i\n"; }

        Jenda
        Enoch was right!
        Enjoy the last years of Rome.