From 50419d916de6240d6dd8ea2af69b628db0c287ba Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Mon, 28 Nov 2011 13:15:17 -0600 Subject: make add_symbol go through ->namespace too --- lib/Package/Stash/PP.pm | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/Package/Stash/PP.pm b/lib/Package/Stash/PP.pm index b3a8a52..f60ac4a 100644 --- a/lib/Package/Stash/PP.pm +++ b/lib/Package/Stash/PP.pm @@ -135,8 +135,6 @@ sub add_symbol { my ($name, $sigil, $type) = $self->_deconstruct_variable_name($variable); - my $pkg = $self->name; - if (@_ > 2) { $self->_valid_for_type($initial_value, $type) || confess "$initial_value is not of type $type"; @@ -152,13 +150,14 @@ sub add_symbol { my $last_line_num = $opts{last_line_num} || ($first_line_num ||= 0); # http://perldoc.perl.org/perldebguts.html#Debugger-Internals - $DB::sub{$pkg . '::' . $name} = "$filename:$first_line_num-$last_line_num"; + $DB::sub{$self->name . '::' . $name} = "$filename:$first_line_num-$last_line_num"; } } - no strict 'refs'; - no warnings 'redefine', 'misc', 'prototype'; - *{$pkg . '::' . $name} = ref $initial_value ? $initial_value : \$initial_value; + my $namespace = $self->namespace; + my $gv = $namespace->{$name} || Symbol::gensym; + *$gv = ref $initial_value ? $initial_value : \$initial_value; + $namespace->{$name} = *$gv; } sub remove_glob { -- cgit v1.2.3-54-g00ecf