X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FStash%2FManip.pm;h=944eab38f7cd4b40ea10c49641d5422da4197b81;hb=56a29840c0b7b0c4a09243ea05400c3df8ad0823;hp=38177c703890b2a7e85fa39dcc0ce5c1b6b30132;hpb=30d1a0987f7c01aad0c45be6b6cf6eada670007a;p=gitmo%2FPackage-Stash-PP.git diff --git a/lib/Stash/Manip.pm b/lib/Stash/Manip.pm index 38177c7..944eab3 100644 --- a/lib/Stash/Manip.pm +++ b/lib/Stash/Manip.pm @@ -24,6 +24,9 @@ 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. + =head1 METHODS =cut @@ -75,23 +78,23 @@ sub namespace { '@' => 'ARRAY', '%' => 'HASH', '&' => 'CODE', + '' => 'IO', ); sub _deconstruct_variable_name { my ($self, $variable) = @_; - (defined $variable) + (defined $variable && length $variable) || confess "You must pass a variable name"; my $sigil = substr($variable, 0, 1, ''); - (defined $sigil) - || confess "The variable name must include a sigil"; - - (exists $SIGIL_MAP{$sigil}) - || confess "I do not recognize that sigil '$sigil'"; - - return ($variable, $sigil, $SIGIL_MAP{$sigil}); + if (exists $SIGIL_MAP{$sigil}) { + return ($variable, $sigil, $SIGIL_MAP{$sigil}); + } + else { + return ("${sigil}${variable}", '', $SIGIL_MAP{''}); + } } }