In a message dated 4/15/2004 12:09:40 PM Eastern Daylight Time, 
[EMAIL PROTECTED] writes:
Learning Perl here..  So I wrote this number guessing script but can't see 
what is wrong with it.  I can never get the solution even when I know it's 
correct.  What am I doing wrong?
[Snipped Code]

It has to do with the scope of guess. You used my twice. Get rid of that my 
in "chomp(my $guess = <STDIN>);  " and then it's good. The $guess being 
evaluated in the while() condition is undef because that is what it has been defined 
to be in that scope. By saying "chomp(my $guess = <STDIN>);" you're saying 
that this is kind of a new $guess specific to that block, and it doesn't even 
exist outside of it.

-will
(the above message is double rot13 encoded for security reasons)

Most Useful Perl Modules
-strict
-warnings
-Devel::DProf
-Benchmark
-B::Deparse
-Data::Dumper
-Clone (a Godsend)
-Perl::Tidy
-Beautifier

Reply via email to