- #!/usr/bin/perl
- use strict;
- my $count=0;
- print "please input a number between 0-10000 which is int.\n";
- $rand_num=int (rand(10000));
- do{
- $count++;
- chomp( $input_num=<>);
- if ($input_num >$rand_num){
- print "You enter the nubmer is lager than real number.please go on\n";
- }
- else { print "you enter the nubmer is smaler than real number.please go on\n";}
- }while ($input_num != $rand_num);
- print "Right,you only use $count step to cmp!\n";
自己自学perl以来,自己写的第一个perl程序。在网上看到别人写的一个猜数游戏,知道其原理后,自己也写了一段代码。欢迎大家拍砖。
转载于:https://blog.51cto.com/riches/504497