my LIST |
声明变量在LIST中,在词法范围内封闭块。如果指定了一个以上的变量,所有变量都必须用括号括起来。
无
试试下面的例子:
#!/usr/bin/perl -w #by www.gitbook.net my $string = "We are the world"; print "$string\n"; myfunction(); print "$string\n"; sub myfunction { my $string = "We are the function"; print "$string\n"; mysub(); } sub mysub { print "$string\n"; }
这将产生以下结果:
We are the world
We are the function
We are the world
We are the world