NAME

Stash::Manip - routines for manipulating stashes

VERSION

version 0.02

SYNOPSIS

my $stash = Stash::Manip->new('Foo');
$stash->add_package_symbol('%foo', {bar => 1});
# $Foo::foo{bar} == 1
$stash->has_package_symbol('$foo') # false
my $namespace = $stash->namespace;
*{ $namespace->{foo} }{HASH} # {bar => 1}

DESCRIPTION

Manipulating stashes (Perl's symbol tables) is occasionally necessary, but incredibly messy, and easy to get wrong. This module hides all of that behind a simple API.

NOTE: Most methods in this class require a variable specification that includes a sigil. If this sigil is absent, it is assumed to represent the IO slot.

METHODS

new $package_name

Creates a new Stash::Manip object, for the package given as the only argument.

name

Returns the name of the package that this object represents.

namespace

Returns the raw stash itself.

add_package_symbol $variable $value

Adds a new package symbol, for the symbol given as $variable, and optionally gives it an initial value of $value. $variable should be the name of variable including the sigil, so

Stash::Manip->new('Foo')->add_package_symbol('%foo')

will create %Foo::foo.

remove_package_glob $name

Removes all package variables with the given name, regardless of sigil.

has_package_symbol $variable

Returns whether or not the given package variable (including sigil) exists.

get_package_symbol $variable

Returns the value of the given package variable (including sigil).

remove_package_symbol $variable

Removes the package variable described by $variable (which includes the sigil); other variables with the same name but different sigils will be untouched.

list_all_package_symbols $type_filter

Returns a list of package variable names in the package, without sigils. If a type_filter is passed, it is used to select package variables of a given type, where valid types are the slots of a typeglob ('SCALAR', 'CODE', 'HASH', etc).

BUGS

No known bugs.

Please report any bugs through RT: email bug-stash-manip at rt.cpan.org, or browse to http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Stash-Manip.

SEE ALSO

Class::MOP::Package - this module is a factoring out of code that used to live here

SUPPORT

You can find this documentation for this module with the perldoc command.

perldoc Stash::Manip

You can also look for information at:

AUTHOR

Jesse Luehrs <doy at tozt dot net>

Mostly copied from code from Class::MOP::Package, by Stevan Little and the Moose Cabal.

COPYRIGHT AND LICENSE

This software is copyright (c) 2010 by Jesse Luehrs.

This is free software; you can redistribute it and/or modify it under the same terms as perl itself.