MOP4Import::Pairs - pragma dispatcher for name => [@pragma]... style protocol
package YourExporter; use MOP4Import::Pairs -as_base, qw/Opts m4i_opts/; sub import { my $myPack = shift; my Opts $opts = m4i_opts([caller]); # Invoke declare_foobar for each $name => $pragmas pairs. $myPack->dispatch_pairs_as_declare(foobar => $opts, @_); } sub declare_foobar { (my $myPack, my Opts $opts, my ($name, @pragmas)) = m4i_args(@_); ... } #----------------------------------- # Then you can use above module in other script like following #----------------------------------- use YourExporter ( xxx => [1..3], yyy => [4..6] ); # Above is equivalent of following: BEGIN { YourExporter->declare_foobar(__PACKAGE__, xxx, 1..3); YourExporter->declare_foobar(__PACKAGE__, yyy, 4..6); }
This module provides name => [@pragma_list] style dispatcher of MOP4Import::Declare pragmas. Mainly used from MOP4Import::Types.
name => [@pragma_list]
This module does not provide "import" itself. Instead, this provides a helper method dispatch_pairs_as_declare to implement "import".
dispatch_pairs_as_declare
This basically does following:
sub dispatch_pairs_as_declare { (my $myPack, my $pragma, my Opts $opts, my (@pairs)) = @_; my $method = "declare_$pragma"; while (my ($typename, $pragma_list) = splice @pairs, 0, 2) { $myPack->$method($opts, $typename, @$pragma_list); } }
Kobayashi, Hiroaki <hkoba@cpan.org>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install MOP4Import::Declare, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MOP4Import::Declare
CPAN shell
perl -MCPAN -e shell install MOP4Import::Declare
For more information on module installation, please visit the detailed CPAN module installation guide.