Perl语法错误:Bareword在运营商预期的位置找到

时间:2011-09-25 11:37:40

标签: perl

正如标题所示,我怎么能做到这一点?

我一直在关注教程,但是我收到了语法错误:

Bareword found where operator expected at arrays_and_variables.pl line
26, near "$2names"
        (Missing operator before names?) syntax error at
arrays_and_variables.pl line 26, near "$2names " Execution of
arrays_and_variables.pl aborted due to compilation errors.

我到目前为止的代码是:

@names = ('james','dylan','max');

# join elements of array into a schalar variable.
$2names = join ('', @names);
print $s2names;

1 个答案:

答案 0 :(得分:5)

2names是无效的变量名称。名称不能以数字开头 - 它们必须以字母或下划线开头。