您现在的位置是:网站首页> 编程资料编程资料
perl中的$a和$b介绍_perl_
2023-05-26
348人已围观
简介 perl中的$a和$b介绍_perl_
即使打开了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.
相关内容
- 使用 use re debug 查看正则表达式的匹配过程_perl_
- perl模块Data::Dumper应用一例分享_perl_
- perl获取日期与时间的实例代码_perl_
- perl比较两个文件字符串的实例代码_perl_
- Linux/Unix下安装Perl模块的两种方法分享_perl_
- Perl中chomp和chop的区别介绍_perl_
- perl中chomp的使用介绍(chop和chomp函数区别)_perl_
- 一行代码解决 perl输入 排序 输出问题_perl_
- perl ping检测功能脚本代码_perl_
- perl pop push shift unshift实例介绍_perl_
