【发布时间】:2011-11-17 01:20:51
【问题描述】:
从http://perldoc.perl.org/perlrequick.html#Search-and-replace获取的以下代码sn-p给了我
Bareword 在 blub.pl 第 2 行附近的操作员预期的位置找到 “s/狗/猫/r”
这里有什么问题?我在 Windows XP 上使用 Perl 5.12.4。
代码:
$x = "I like dogs.";
$y = $x =~ s/dogs/cats/r;
print "$x $y\n";
【问题讨论】:
-
嗯,到底是什么意思?最后的
r是什么? -
@BrianRoach 这是非破坏性修饰符
-
呃,好的。所以,我是对的......但只是因为我从未使用过 perl 5.14 :-D