#!/usr/bin/perl -wT use strict; my $low = 0; my $high = 40000; # guesses integet between two other integers my $ans = ''; while ($ans ne 'C') { my $mid=int (($low+$high)/2); print "is $mid low, high or correct? :"; $ans=; $ans=uc(substr($ans,0,1)); if('L' eq $ans){ $low = $mid+1; }elsif('H' eq $ans){ $high = $mid-1; }elsif($ans ne 'C') { print "bad input\n"; } } print "thank you for playing\n";