Dưới đây là một chương trình thử nghiệm ngắn:Tại sao Perl đè bẹp mảng của tôi?
sub foo($;@) {
my $sql = shift;
my @params = @_;
print "sql: $sql\n";
print "params: " . join(",", @params);
}
sub bar($;@) {
foo(@_);
}
bar("select * from blah where x = ? and y = ?",2,3);
print "\n";
Tại sao là sản phẩm này:
sql: 3
params:
Thay vì điều này?
sql: select * from blah where x = ? and y = ?
params: 2,3