Rodrigo Tavares wrote:
Hello,

Hello,

I bought a book about Programming Perl, there is a
exercise :

1) Enter with a number and print asterisks (1..30)
ex: if you type six have go to screen:

******

See the below code :

if (($num1 >= 1 && $num1 <= 30) {
     for (my $i=1 ; $i < 30 ; $i++)
      {
        while ($num1 == $i)
         {
          print "*";
         }
      }
}
This script is in loop. I don't understand, therefore the line command while, could be stop after bow.

What's wrong ?

You don't need any loops in there:

if ( $num1 >= 1 && $num1 <= 30 )
{
    print '*' x $num1;
}



John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to