Linux中国论坛's Archiver

lydr 发表于 2006-12-15 15:15

一个猜数perl脚本

这个脚本是我的一个练习~~,挺有趣的,包括了必要的基础知识~~
[code]#!perl -w
$rand=int(1 + rand 100);
while (1) {
        print "Please input number from 1 to 100:";
        chomp($input=<>);
        if ($input =~ /quit|exit|^\s*$/i) {
        print "Sorry,You lose!\nThe rand-number is: $rand\n";
        last;
        } elsif ($input lt$rand) {
                print "Too small,Try input again!\n";
        } elsif ($input eq $rand) {
                print "You win!\n";
                last;
        }else {
                print "Tool large.Try input again!\n";
        }
}[/code]

页: [1]

Powered by Discuz! Archiver 6.1.0  © 2001-2007 Comsenz Inc.