子程序的运用

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

@a=(); #定义一个全局数组@a 
$a=0;  #定义一个全局标量$a
sub greet{
  push(@a ,@_[0]);
  if($a==0){
  	print "hi ".@a[$a]."! you are the first one here\n";
    $a++;
  }else{
  	#print "hi ".@a[$a]."!".@a[--$a]." is also here";
  	print "hi ".@a[$a].". I've seen:";
  	for($i=0;$i<$a;$i++){
  		print @a[$i]." ";
  	}
  	print "\n";
  	$a++;
  }
}
&greet("fred");
&greet("barney");
&greet("wilma");
&greet("betty");