打印欢迎信息并输出前一位来宾

#!/usr/bin/perl

@names=qw();#全局变量,用来存放所有用户的姓名
print "@names";
sub greet
{
        #push(@names,@_)
        if( "@names" eq "" ) #判断有没有用户来了
        {
                print "@_ you are the first one to be here !\n\n";
        }
        else
        {
                $name=pop(@names);
                print "$name before you !\n";
                print "@_ welcome you !\n\n";
        }
        push(@names,@_);
}
&greet(lily);
&greet(lucy);
&greet(Green);

你可能感兴趣的:(打印欢迎信息并输出前一位来宾)