diff options
author | Chad Granum <exodist7@gmail.com> | 2016-07-09 15:58:13 -0700 |
---|---|---|
committer | Chad Granum <exodist7@gmail.com> | 2016-07-09 15:59:42 -0700 |
commit | b417db7085e6946d98176767f8eacbf5ea0e1606 (patch) | |
tree | 3355560f1708cd1530e0c08365ca146de37593c0 /lib | |
parent | 698e3c0f0a6a49339c5b1caed684559075328390 (diff) |
Provide extra info to custom symbol setters
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Importer.pm | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/lib/Importer.pm b/lib/Importer.pm index c3381d5..ee3ffd2 100644 --- a/lib/Importer.pm +++ b/lib/Importer.pm @@ -2,7 +2,7 @@ package Importer; use strict qw/vars subs/; # Not refs! use warnings; no warnings 'once'; -our $VERSION = '0.012'; +our $VERSION = '0.013'; my %SIG_TO_SLOT = ( '&' => 'CODE', @@ -581,7 +581,7 @@ sub { *{"$into\\::\$_[0]"} = \$_[1] } my $new_name = join '' => ($spec->{'-prefix'} || '', $spec->{'-as'} || $name, $spec->{'-postfix'} || ''); # Set the symbol (finally!) - $set_symbol->($new_name, $ref); + $set_symbol->($new_name, $ref, sig => $sig, symbol => $symbol, into => $into, from => $from, spec => $spec); # The remaining things get skipped with a custom setter next if $custom_set; @@ -814,6 +814,37 @@ implemented). $CARP{cluck}->("This will cluck"); $CARP{croak}->("This will croak"); +The first two arguments to the custom sub are the name (no sigil), and the +reference. The additional arguments are key/value pairs: + + sub set_symbol { + my ($name, $ref, %info) = @_; + } + +=over 4 + +=item $info{from} + +Package the symbol comes from. + +=item $info{into} + +Package to which the symbol should be added. + +=item $info{sig} + +The sigil that should be used. + +=item $info{spec} + +Extra details. + +=item $info{symbol} + +The original symbol name (with sigil) from the original package. + +=back + =item @SYMBOLS (optional) Symbols you wish to import. If no symbols are specified then the defaults will |