【问题标题】:Unmatched ( in regex; marked by <-- HERE in m/( <-- HERE error perl不匹配(在正则表达式中;由 <-- HERE in m/( <-- HERE 错误 perl
【发布时间】:2015-10-09 23:37:15
【问题描述】:

我无法修复此错误...

@temp=split(/(/)/,$headerLine);

出现此错误

Unmatched ( in regex; marked by <-- HERE in m/( <-- HERE

【问题讨论】:

    标签: perl syntax-error


    【解决方案1】:

    使用

    @temp=split(/(\/)/,$headerLine);
    

    @temp=split(m&(/)&,$headerLine);
    

    括号中的斜线会提前终止您的正则表达式。

    【讨论】:

    • m{(/)} 甚至是 m(/)>... 取决于看起来更具可读性的内容。
    • 我认为三个提案就足够了。 =)
    • 当然,三个就够了。
    【解决方案2】:

    您的第二个 / 字符正在终止正则表达式,因此 Perl 将您的代码解释为:

    @temp=split /(/
    

    后面是垃圾。

    简单地转义文字 /:

    @temp=split(/(\/)/, $headerLine)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-03-29
      • 1970-01-01
      • 2014-12-03
      • 2016-06-29
      • 1970-01-01
      • 1970-01-01
      • 2012-01-20
      • 1970-01-01
      相关资源
      最近更新 更多