perl 中的$a和$b perl中的$a和$b介绍

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

perl 中的$a和$b perl中的$a和$b介绍

  2021-03-18 我要评论
想了解perl中的$a和$b介绍的相关内容吗,在本文为您仔细讲解perl 中的$a和$b的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点: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.

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们