perl中打印随机数
#!/usr/bin/perl my $rand = int (1+ rand 100);#print "this is $rand"; #调试程序
while (1) { #建立死循环
print "Please this 1 to 100 number:";
chomp(my $guess = );
if ($guess =~ /quit|exit|^\s*$/i){ #判断条件
print "Number is $run\n";
last; #如果执行成功将退出循环
}
elsif ($guess < $run ){
print "Too small.try again\n";#提示用户输入和正确的数字相差距离
}
elsif ($guess == $run){
print "That right\n";
last;
}
else{
print "too large.try again!\n";
}
}
页:
[1]