jonagondos has asked for the wisdom of the Perl Monks concerning the following question:
why is it that when i dont give any user input the else statement isnt executed saying "no user input"? it just tells me circumference is equal to 0
#!/usr/bin/perl $radius_times = 2; $radius_times_2 = 3.141592654; $radius_times_2 *= $radius_times; while (1) { print "enter the radius\n"; $user_radius = <STDIN>; chomp($user_radius); if (defined($user_radius)) { $user_radius *= $radius_times_2; print "circumference is equal to $user_radius\n"; } else { print "no user input"; } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: else statement not being executed
by greengaroo (Hermit) on Nov 14, 2012 at 14:34 UTC | |
Re: else statement not being executed
by choroba (Cardinal) on Nov 14, 2012 at 14:35 UTC | |
Re: else statement not being executed
by flexvault (Monsignor) on Nov 14, 2012 at 14:44 UTC | |
by jonagondos (Novice) on Nov 14, 2012 at 14:50 UTC | |
Re: else statement not being executed (tangential note))
by ww (Archbishop) on Nov 16, 2012 at 14:19 UTC |
Back to
Seekers of Perl Wisdom