use strict; use warnings; use diagnostics; # explain the warnings ! # guesses integet between two other integers sub recuGuess($$){ my($low,$high)=@_; my $mid=int (($low+$high)/2); print "is $mid low, high or correct? :"; my $ans=; $ans=uc(substr($ans,0,1)); if('C' eq $ans){ print "thank you for playing\n"; }elsif('L' eq $ans){ &recuGuess($mid+1,$high); }elsif('H' eq $ans){ &recuGuess($low,$mid-1); }else{ print "bad input\n"; &recuGuess($low,$high); } } recuGuess(1,40000);