} elsif ($p =~ /[\@\%]/) {
push @args, @_;
last;
- } elsif ($p eq '_' && @_ == 0) {
- push @args, $_;
+ } elsif ($p eq '_') {
+ shift; # without prototype, this argument wouldn't have been passed
} else {
push @args, shift;
}
sub _wrap {
my ($name, $proto, $i, $args, $cr, $opts) = @_;
- if ($proto =~ /(\\?)(\[[^\]]+\]|[^\];])(.*)/g) {
+ while ($proto =~ s/(\\?)(\[[^\]]+\]|[^\];])//) {
my ($ref, $p) = ($1, $2);
- $proto = $3;
$p = $1 if $p =~ /^\[([^\]]+)\]/;
my $cur = '$_[' . $i . ']';
if ($ref) {
} else {
$args .= $cur . ', ';
}
- return _wrap($name, $proto, ($i + 1), $args, $cr, $opts);
- } else {
- $args =~ s/,\s*$//;
- return $name . '(' . $args . ')';
+ ++$i;
}
+ $args =~ s/,\s*$//;
+ return $name . '(' . $args . ')';
}
sub _check_name {