From: Stevan Little Date: Sat, 25 Feb 2006 17:51:09 +0000 (+0000) Subject: improve get_package_variable; X-Git-Tag: 0_20~12 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=18697ac89863ce1db065d8d1eda6ae71c9b1594c;p=gitmo%2FClass-MOP.git improve get_package_variable; --- diff --git a/lib/Class/MOP/Class.pm b/lib/Class/MOP/Class.pm index d7073f8..099e1fa 100644 --- a/lib/Class/MOP/Class.pm +++ b/lib/Class/MOP/Class.pm @@ -463,12 +463,10 @@ sub get_package_variable { my ($sigil, $name) = ($variable =~ /^(.)(.*)$/); no strict 'refs'; # try to fetch it first,.. see what happens - eval '\\' . $sigil . $self->name . '::' . $name; + my $ref = eval '\\' . $sigil . $self->name . '::' . $name; confess "Could not get the package variable ($variable) because : $@" if $@; # if we didn't die, then we can return it - # NOTE: - # this is not ideal, better suggestions are welcome - eval '\\' . $sigil . $self->name . '::' . $name; + return $ref; } sub remove_package_variable {