猜字游戏

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

#!/usr/bin/perl -w

#creat on 2012-04-27
#author wanghz

$im_thinking_of=int(rand 10);
     print "Pick a number:";
while ($im_thinking_of<10){
$guess=<STDIN>;
chomp $guess;
if ($guess > $im_thinking_of) 
{
	print "You guessed too high!\nPick a number:";
	next;
}
elsif ($guess < $im_thinking_of)
{
	print "You guessed too low!\nPick a number:";
	next;
}
else 
{
        print "You guessed it right!\n";
	last;
}
}