};
my $method = $code->new(sub {
$_->(@_) for @{$modifier_table->{before}};
- my @rval;
+ my (@rlist, $rval);
if (defined wantarray) {
- @rval = $modifier_table->{around}->{cache}->(@_);
+ if (wantarray) {
+ @rlist = $modifier_table->{around}->{cache}->(@_);
+ }
+ else {
+ $rval = $modifier_table->{around}->{cache}->(@_);
+ }
}
else {
$modifier_table->{around}->{cache}->(@_);
}
$_->(@_) for @{$modifier_table->{after}};
return unless defined wantarray;
- return wantarray ? @rval : $rval[0];
+ return wantarray ? @rlist : $rval;
});
$MODIFIERS{$method} = $modifier_table;
$method;