NAME
Symbol::Util - Additional utils for Perl symbols manipulation
SYNOPSIS
use Symbol::Util ':all';
my $caller = caller;
*{ fetch_glob("${caller}::foo") } = sub { "this is foo" };
my $coderef = fetch_glob("${caller}::bar", "CODE");
sub baz { 42; }
export_glob($caller, "baz");
print join "\n", keys %{ stash("main") };
delete_glob("${caller}::foo", "CODE");
use constant PI => 3.14159265;
delete_sub "PI"; # remove constant from public API
require YAML;
export_package(__PACKAGE__, "YAML", "Dump"); # import YAML::Dump
unexport_package(__PACKAGE, "YAML"); # remove imported symbols
no Symbol::Util; # clean all symbols imported from Symbol::Util
DESCRIPTION
This module provides a set of additional functions useful for Perl
symbols manipulation.
All Perl symbols from the same package are organized as a stash. Each
symbol (glob) contains one or more of following slots: `SCALAR',
`ARRAY', `HASH', `CODE', `IO', `FORMAT'. These slots are also accessible
as standard variables or bare words.
The Perl symbols table is directly accessible with typeglob prefix but
it can be difficult to read and problematic if strict mode is used. Also
the access to stash, glob and one of its slot have different syntax
notation.
`stash' and `fetch_glob' functions gets stash or glob without need to
use `no strict 'refs''.
`delete_glob' function allows to delete specific slot of symbol name
without deleting others.
`delete_sub' removes the symbol from class API. This symbol won't be
available as an object method.
`export_glob' function exports a glob to the target package.
`export_package' works like Exporter module and allows to export symbols
from one package to other.
`unexport_package' allows to delete previously exported symbols.
AUTHOR
Piotr Roszatycki <dexter@cpan.org>
LICENSE
Copyright (c) 2009, 2012 Piotr Roszatycki <dexter@cpan.org>.
This is free software; you can redistribute it and/or modify it under
the same terms as perl itself.
See http://dev.perl.org/licenses/artistic.html