revert local $\@ around require to avoid eating errors
[gitmo/Role-Tiny.git] / lib / Method / Generate / Accessor.pm
index 13e6ccc..4a8ecd3 100644 (file)
@@ -372,7 +372,7 @@ sub _generate_simple_set {
   my $simple = "${me}->{${name_str}} = ${value}";
 
   if ($spec->{weak_ref}) {
-    { local $@; require Scalar::Util; }
+    require Scalar::Util;
 
     # Perl < 5.8.3 can't weaken refs to readonly vars
     # (e.g. string constants). This *can* be solved by:
@@ -387,7 +387,7 @@ sub _generate_simple_set {
 
       eval { Scalar::Util::weaken($simple); 1 } or do {
         if( \$@ =~ /Modification of a read-only value attempted/) {
-          { local $@; require Carp; }
+          require Carp;
           Carp::croak( sprintf (
             'Reference to readonly value in "%s" can not be weakened on Perl < 5.8.3',
             $name_str,