在perl中,如果定义了一个数组,有时候可以直接使用@test 表示数组元素的数量。
不妨看一个小例子:运行结果为:
a b c d e
6
当,@test用在数学计算中,那么它就表示数值,也就是元素的个数。
不妨看一个小例子:
- #! /ur/bin/perl
- @test=qw/a b c d e/;
- $n=1;
- $m=1+@test;
- print "@test\n";
- print "$m\n";
a b c d e
6
当,@test用在数学计算中,那么它就表示数值,也就是元素的个数。
编辑回复