华域联盟 perl perl中的$a和$b介绍

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.

本文由 华域联盟 原创撰写:华域联盟 » perl中的$a和$b介绍

转载请保留出处和原文链接:https://www.cnhackhy.com/76978.htm

本文来自网络,不代表华域联盟立场,转载请注明出处。

作者: sterben

发表回复

联系我们

联系我们

2551209778

在线咨询: QQ交谈

邮箱: [email protected]

工作时间:周一至周五,9:00-17:30,节假日休息

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

关注微博
返回顶部