http://qs321.pair.com?node_id=1149514

tryingnottofailmytes has asked for the wisdom of the Perl Monks concerning the following question:

Hi guys. Sorry to bother you again. I've been working on this for an hour trying to get the loop in the subroutine to loop five times. Its only running the main program. I think the probelm is somewhere either in the calling or the names of the arguments. Any help is appreciated. I know this stuff is super simple and annoying to answer for the newbs.
my $messagetouser= "What is your favorite Color?"; my $ans = tryagain5 ( $messagetouser ); if ($ans) { print "$ans\n"; } else { print "You didn't reply! Goodbye.\n"; exit; } #print $answer, "\n"; sub callandresponse { my ($messagetouser)=@_; print $messagetouser,"\n"; my $ans=<STDIN>; chomp $ans; return $ans; } sub tryagain5 { my($messagetouser)=@_; my $ans = callandresponse ($messagetouser); my $count=1; while ($count < 5 and $ans =~ /^\s*\n/) { $count++; $ans = callandresponse ($messagetouser); } if ($ans =~ /^\s*\n/) { return 0; } else { return $ans;} }
I really can't figure out why the loop isn't running......I know the answer is simple but I just can't figure it out.