X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FSub-Prototype-Util.git;a=blobdiff_plain;f=lib%2FSub%2FPrototype%2FUtil.pm;h=a92647f6a4d224985ff72ac11dea3fd75ed980ca;hp=91520b823361f417e9d715e1d3f7f63d4888a04e;hb=39b18d4f8f133cb03d47a486464c5c96cb148d5f;hpb=4e977a0b1db65e44cf4c6184792208a7930c34f4 diff --git a/lib/Sub/Prototype/Util.pm b/lib/Sub/Prototype/Util.pm index 91520b8..a92647f 100644 --- a/lib/Sub/Prototype/Util.pm +++ b/lib/Sub/Prototype/Util.pm @@ -72,19 +72,23 @@ sub flatten { if ($1) { my $a = shift; my $r = _check_ref $a, $p; - my %deref = ( - SCALAR => sub { push @args, $$a }, - ARRAY => sub { push @args, @$a }, - HASH => sub { push @args, %$a }, - GLOB => sub { push @args, *$a }, - CODE => sub { push @args, &$a } - ); - $deref{$r}->(); + push @args, $r eq 'SCALAR' + ? $$a + : ($r eq 'ARRAY' + ? @$a + : ($r eq 'HASH' + ? %$a + : ($r eq 'GLOB' + ? *$a + : &$a # _check_ref ensures this must be a code ref + ) + ) + ); } 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; }