X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FSub%2FPrototype%2FUtil.pm;h=a981d27498ac393d4d383c8c39d2af27e8190c49;hb=e0d0c3b61349870e1009e833116c10a794e3b6b8;hp=2c47ba649acfc266dd06c964ba4f4451f2ff94a1;hpb=07e369ea55f844ee3160639eec14cee5884b1290;p=perl%2Fmodules%2FSub-Prototype-Util.git diff --git a/lib/Sub/Prototype/Util.pm b/lib/Sub/Prototype/Util.pm index 2c47ba6..a981d27 100644 --- a/lib/Sub/Prototype/Util.pm +++ b/lib/Sub/Prototype/Util.pm @@ -14,13 +14,13 @@ Sub::Prototype::Util - Prototype-related utility routines. =head1 VERSION -Version 0.09 +Version 0.10 =cut use vars qw<$VERSION>; -$VERSION = '0.09'; +$VERSION = '0.10'; =head1 SYNOPSIS @@ -72,7 +72,9 @@ sub _clean_msg { $msg; } -=head2 C +=head2 C + + my @flattened = flatten($proto, @args); Flattens the array C<@args> according to the prototype C<$proto>. When C<@args> is what C<@_> is after calling a subroutine with prototype C<$proto>, C returns the list of what C<@_> would have been if there were no prototype. @@ -118,7 +120,10 @@ sub flatten { return @args; } -=head2 C +=head2 C + + my $wrapper = wrap($name, %opts); + my $wrapper = wrap({ $name => $proto }, %opts); Generates a wrapper that calls the function C<$name> with a prototyped argument list. That is, the wrapper's arguments should be what C<@_> is when you define a subroutine with the same prototype as C<$name>. @@ -132,7 +137,7 @@ In this case, C<$name> must be a hash reference that holds exactly one key / val my $push = wrap { 'CORE::push' => '\@$' }; # only pushes 1 arg -Others arguments are seen as key / value pairs that are meant to tune the code generated by L. +The remaining arguments C<%opts> are treated as key / value pairs that are meant to tune the code generated by L. Valid keys are : =over 4 @@ -279,7 +284,10 @@ sub wrap { return $call; } -=head2 C +=head2 C + + my @res = recall($name, @args); + my @res = recall({ $name => $proto }, @args); Calls the function C<$name> with the prototyped argument list C<@args>. That is, C<@args> should be what C<@_> is when you call a subroutine with C<$name> as prototype.