2 Sub::Prototype::Util - Prototype-related utility routines.
8 use Sub::Prototype::Util qw/flatten recall/;
11 my @args = ( \@a, 1, { d => 2 }, undef, 3 );
13 my @flat = flatten '\@$;$', @args; # ('a', 'b', 'c', 1, { d => 2 })
14 recall 'CORE::push', @args; # @a contains 'a', 'b', 'c', 1, { d => 2 }, undef, 3
17 Prototypes are evil, but sometimes you just have to bear with them,
18 especially when messing with core functions. This module provides
19 several utilities aimed at facilitating "overloading" of prototyped
22 They all handle 5.10's "_" prototype.
25 "flatten $proto, @args"
26 Flattens the array @args according to the prototype $proto. When @args
27 is what @_ is after calling a subroutine with prototype $proto,
28 "flatten" returns the list of what @_ would have been if there were no
32 Calls the function $name with the prototyped argument list @args. That
33 is, @args should be what @_ is when you define a subroutine with the
34 same prototype as $name. For example,
37 recall 'CORE::push', $a, 1, 2, 3;
39 will call "push @$a, 1, 2, 3" and so fill the arrayref $a with "1, 2,
40 3". This is especially needed for core functions because you can't
44 The functions "flatten" and "recall" are only exported on request,
45 either by providing their name or by the ':funcs' and ':all' tags.
48 Carp, Exporter (core modules since perl 5), Scalar::Util (since 5.7.3).
51 Vincent Pit, "<perl at profvince.com>", <http://www.profvince.com>.
53 You can contact me by mail or on #perl @ FreeNode (vincent or
57 Please report any bugs or feature requests to "bug-sub-prototype-util at
58 rt.cpan.org", or through the web interface at
59 <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Sub-Prototype-Util>. I
60 will be notified, and then you'll automatically be notified of progress
61 on your bug as I make changes.
64 You can find documentation for this module with the perldoc command.
66 perldoc Sub::Prototype::Util
68 Tests code coverage report is available at
69 <http://www.profvince.com/perl/cover/Sub-Prototype-Util>.
72 Copyright 2008 Vincent Pit, all rights reserved.
74 This program is free software; you can redistribute it and/or modify it
75 under the same terms as Perl itself.