Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我写了一个小测试脚本。
#!/usr/bin/perl -w use strict; my $head="a b"; sub test { my @arr=split / /,@_; print $arr[0]; } test $head;
1相反,我实际上期待的是输出a。谁能告诉我我错在哪里
1
a
的操作数在标量上下文split中求值,在标量上下文中求值为( )@_中的元素数。你要@_1
split
@_
sub test { my @arr = split / /, $_[0]; print $arr[0]; }