- #!/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程序。在网上看到别人写的一个猜数游戏,知道其原理后,自己也写了一段代码。欢迎大家拍砖。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。