Symbol::Methods - Symbol manipulation methods for packages.
This package introduces several subs that can be called as methods on packages. These subs allow you to modify symbol tables. This module does not do anything that can't be done with Package::Stash, or other tools. What this module does give you is a package method interface.
use Symbol::Methods; # Move a symbol, the old name will be removed Foo::Bar->symbol::move('&foo' => '&bar'); # Alias a symbol, both names will work Foo::Bar->symbol::alias('&foo' => '&bar'); # Get a reference to the symbol my $ref = Foo::Bar->symbol::fetch('%foo'); # Delete a symbol (and return the reference that was removed) my $ref = Foo::Bar->symbol::delete('&foo'); # Check if a symbol exists. if(Foo::Bar->symbol::exists('&foo')) { ... }
These methods all exist in the symbol:: namespace. These can always be called as methods on any package thanks to the way perl resolves methods.
symbol::
These will grab the symbol specified by $SYMBOL and make it available under the name in $NEW_NAME. alias() will leave the symbol available under both names, move() will remove it from the original name.
$SYMBOL
$NEW_NAME
alias()
move()
$SYMBOL must be a string identifying the symbol. The symbol string must include the sigil unless it is a subroutine. You can provide a fully qualified symbol name, or it will be assumed the symbol is in $PACKAGE.
$PACKAGE
$NEW_NAME must be a string identifying the symbol. The string may include a symbol, or the sigil from the $SYMBOL string will be used. The string can be a fully qualified symbol name, or it will be assumed that the new name is in $PACKAGE.
These will both find the specified symbol and return a reference to it. fetch() will simply return the reference, delete() will remove the symbol before returning the reference.
fetch()
delete()
This will check if the specified symbol exists. If the symbol exists a true value is returned. If the symbol does not exist a false value is returned.
Symbol::Alias Allows you to set up aliases within a package at compile-time.
Symbol::Delete Allows you to remove symbols from a package at compile time.
Symbol::Extract Allows you to extract symbols from packages and into variables at compile time.
Symbol::Move allows you to rename or relocate symbols at compile time.
The source code repository for symbol can be found at http://github.com/exodist/Symbol-Move.
Copyright 2015 Chad Granum <exodist7@gmail.com>.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See http://dev.perl.org/licenses/
To install Symbol::Move, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Symbol::Move
CPAN shell
perl -MCPAN -e shell install Symbol::Move
For more information on module installation, please visit the detailed CPAN module installation guide.