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

Aham, I see, but how can you use a while loop to print all numbers between $number1 and $number2 ( I mean if they are both user-defined)?

Replies are listed 'Best First'.
Re^3: SIMPLE way to write these?
by choroba (Cardinal) on Feb 04, 2014 at 14:24 UTC
    Ahem, just replace 1 (that is not followed by 0) with $number1; and similarly, replace 10 with $number2.
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
      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"; }