这是代码:
sub function($&) {
my $param1 = shift;
my $code = shift;
# do something with $param1 and $code
}
如果我尝试这样称呼它:
function("whatever") {
print "i'm inside the coderef\n";
}
我明白了Not enough arguments for MyPackage::function at x.pl line 5, near ""whatever" { "
。我怎样才能调用它而不必sub
在代码块前面添加?