【问题标题】:Perl syntax error: Bareword found where operator expectedPerl 语法错误:Bareword found where operator expected
【发布时间】:2011-09-25 11:37:39
【问题描述】:

正如标题所示,我该如何做到这一点?

我一直在学习一个教程,但是我收到了一个语法错误:

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;

【问题讨论】:

  • 使用严格;使用警告;在你的程序顶部将有助于捕捉这些东西。

标签: perl


【解决方案1】:

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

【讨论】:

  • 啊!我明白了,代码对我来说看起来不错:D,知道这很简单:P 谢谢
  • @Ben:很高兴为您提供帮助。您介意我将您帖子的标题更改为“Perl 语法错误:Bareword 在操作员期望的位置找到”这样的内容,以便将来遇到同样问题的人更容易搜索到吗?
猜你喜欢
  • 2021-02-08
  • 1970-01-01
  • 2011-03-08
  • 1970-01-01
  • 2017-12-29
  • 1970-01-01
  • 2023-03-03
  • 1970-01-01
  • 2012-05-25
相关资源
最近更新 更多