s///r; 在Sublime中破坏了语法高亮。

huangapple go评论91阅读模式
英文:

s///r; breaks syntax highlighter in Sublime

问题

我有一个Perl脚本,我正在使用Sublime编辑器。

在下面这行代码之后,语法高亮器出现问题。
my $new = ($old =~ s/cat/dog/r);

这是因为/r。但为什么呢?

如何解决这个问题或有没有其他选择?

英文:

I have a Perl script and editor I'm using is Sublime.

After the below line of code, the syntax highlighter breaks.
<br>my $new = ($old =~ s/cat/dog/r);<br>

s///r; 在Sublime中破坏了语法高亮。

This is because of /r. But why?

How to tackle this problem or any alternatives?

答案1

得分: 3

这是您版本中存在的问题,即v3.1.1,也称为构建3176。

这个问题在v3.2,也称为构建3200中已经修复。

如果您拥有许可证,升级到最新的v3.x(v3.2.2)在您当前的许可证下是免费的。

然而,我强烈建议升级到最新版本的Sublime Text 4,它是Build 4143。我使用开发版本,稍微领先于公共版本,您的代码在那里也被正确地突出显示:

代码在Build 4143中看起来一样。

如果您是Sublime Text的持牌用户,您需要一张新的ST4许可证,但有如此多的新功能和改进,远远超过旧版本,支持开发人员绝对是值得的。

英文:

This is a problem that exists in your version, v3.1.1 aka build 3176.

s///r; 在Sublime中破坏了语法高亮。

This was fixed in v3.2 aka build 3200.

s///r; 在Sublime中破坏了语法高亮。

Upgrading to the latest v3.x (v3.2.2) is covered under your current license, if you have one.

However, I strongly recommend updating to the latest version of Sublime Text 4, which is Build 4143. I use the dev builds, which are slightly ahead of the public builds, and your code is highlighted correctly there as well:

s///r; 在Sublime中破坏了语法高亮。

The code looks the same in Build 4143.

If you're a licensed user of Sublime Text you'll need a new license for ST4, but there are so many new features and improvements over the old version that it's definitely worth it to support the developers.

答案2

得分: 0

r修饰符是在5.14版本中添加的。您的编辑器的高亮显示器显然不知道这个变化。

您可以改用以下方式:

my $new = $old;
$new =~ s/cat/dog/;

合并的写法:

( my $new = $old ) =~ s/cat/dog/;
英文:

The r modifier was added in 5.14. Your editor's highlighter apparently isn't aware of that change.

You could use the following instead:

my $new = $old;
$new =~ s/cat/dog/;

Combined:

( my $new = $old ) =~ s/cat/dog/;

huangapple
  • 本文由 发表于 2023年5月24日 23:42:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/76325288.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定