我在两台不同的机器上运行相同的Perl脚本(Redhat和SUSE).在SUSE上,脚本运行正常,但在Redhat上没有.这是我正在运行的整个脚本:
#!/usr/bin/perl
$str = "Cat|Dog|Bird";
$number = split /\|/, $str;
$type = @_[0];
print "number of args: $number and type is: $type \n";
Run Code Online (Sandbox Code Playgroud)
我得到2个不同的输出
SUSE:
number of args: 3 and type is: Cat
Run Code Online (Sandbox Code Playgroud)
红帽:
number of args: 3 and type is:
Run Code Online (Sandbox Code Playgroud)
我想知道是什么原因导致这个??? 在第一个$type以某种方式初始化
注意:我忽略了警告"标量值@_ [0]更好地写为$ _ [0]",因为如果我改变它没有任何区别.输出将是相同的.