我写的函数有问题...
sub TemplateReplace
{
my($regex, $replacement, $text) = @_;
$text =~ s/($regex)/($replacement)/gs;
}
my $text = "This is a test.";
TemplateReplace("test", "banana", $text);
但它不起作用。我认为参数是在 Perl 中通过引用发送的。然后该行my($regex, $replacement, $text) = @_;
会复制它们吗?我该如何解决?