Home: Fun With Perl: Perl Quizzes - Learn Perl the Fun Way:
Aha vs. Doh



perlplexer
Deleted

Nov 30, 2000, 4:46 AM


Views: 44518
Aha vs. Doh

What does the following code print and _why_?
----------------------Cut-------------------------------
print "aha\n" and exit if (my $foo = 1 and $foo == 1);
print "doh\n";
----------------------Cut-------------------------------


sleuth
Enthusiast

Dec 1, 2000, 9:35 PM


Views: 44518
Re: Aha vs. Doh

 
It prints "Doh",

Becaaaaause, $foo != 1, it isn't defined.

That's a great one, :)

Sleuth


perlplexer
Deleted

Dec 4, 2000, 5:19 AM


Views: 44518
Re: Aha vs. Doh

Yes, sleuth, you are correct!

'my $var' declarations do not become "visible" until after the current statement...

perlplexer