From: Stevan Little Date: Mon, 20 Mar 2006 21:44:40 +0000 (+0000) Subject: 0_22 X-Git-Tag: 0_22^0 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=39ec4f0c40a10d4c0fe31b24acf58a840ed1f38c;p=gitmo%2FClass-MOP.git 0_22 --- diff --git a/lib/Class/MOP/Class.pm b/lib/Class/MOP/Class.pm index 2750b4f..d4a8cab 100644 --- a/lib/Class/MOP/Class.pm +++ b/lib/Class/MOP/Class.pm @@ -523,13 +523,17 @@ sub add_package_variable { *{$self->name . '::' . $name} = $initial_value; } else { - # NOTE: - # We HAVE to localize $@ or all - # hell breaks loose. It is not - # good, believe me, not good. - local $@; - eval $sigil . $self->name . '::' . $name; - confess "Could not create package variable ($variable) because : $@" if $@; + my $e; + { + # NOTE: + # We HAVE to localize $@ or all + # hell breaks loose. It is not + # good, believe me, not good. + local $@; + eval $sigil . $self->name . '::' . $name; + $e = $@ if $@; + } + confess "Could not create package variable ($variable) because : $e" if $e; } } @@ -547,14 +551,17 @@ sub get_package_variable { (defined $variable && $variable =~ /^[\$\@\%]/) || confess "variable name does not have a sigil"; my ($sigil, $name) = ($variable =~ /^(.)(.*)$/); - no strict 'refs'; - # NOTE: - # We HAVE to localize $@ or all - # hell breaks loose. It is not - # good, believe me, not good. - local $@; - my $ref = eval '\\' . $sigil . $self->name . '::' . $name; - confess "Could not get the package variable ($variable) because : $@" if $@; + my ($ref, $e); + { + # NOTE: + # We HAVE to localize $@ or all + # hell breaks loose. It is not + # good, believe me, not good. + local $@; + $ref = eval '\\' . $sigil . $self->name . '::' . $name; + $e = $@ if $@; + } + confess "Could not get the package variable ($variable) because : $e" if $e; # if we didn't die, then we can return it return $ref; }