perl中的$a和$b介绍
即使打开了strict和warnings选项也无妨,下面代码并无错误和警告。
代码如下:
#!/usr/bin/perl use strict; use warnings; sub test { $a = 1; $b = 2; print $a, "\n"; print $b, "\n"; } test(); 1;
下面是perl文档中对这两个变量的解释:
perldoc perlvar
$a
$b Special package variables when using sort(), see "sort" in perlfunc.
Because of this specialness $a and $b don't need to be declared (using use vars, or our()) even when using the "strict 'vars'" pragma. Don't lexicalize them with "my $a" or "my $b" if you want to be able to use them in the sort() comparison block or function.
相关推荐
边城客栈学无止境 2020-07-05
Walter的学习笔记 2020-07-04
A宇 2020-06-14
边城客栈学无止境 2020-06-10
邓博学习笔记 2020-06-03
davidliu00 2020-05-26
ShiShuo 2020-05-16
Aggressivesnail 2020-05-10
ShiShuo 2020-04-26
hanxingwang00 2020-04-22
davidliu00 2020-03-06
ShiShuo 2020-03-06
ShiShuo 2020-03-05
Aggressivesnail 2020-02-28
aaLiweipeng 2020-02-01
amberom 2020-01-16
Walter的学习笔记 2020-01-06