]> git.vpit.fr Git - perl/modules/Perl-Critic-Policy-Dynamic-NoIndirect.git/blobdiff - lib/Perl/Critic/Policy/Dynamic/NoIndirect.pm
Disable strict and warnings when evaluating the code
[perl/modules/Perl-Critic-Policy-Dynamic-NoIndirect.git] / lib / Perl / Critic / Policy / Dynamic / NoIndirect.pm
index 3528d0b0718852e29f815a9dadf4b7f1f7781eb0..068ab88d1ff81018234934d13bea9d2f80c71c54 100644 (file)
@@ -58,24 +58,25 @@ sub violates_dynamic {
 
  my @errs;
  my $wrapper = <<" WRAPPER";
- {
   return;
   package main;
-  no indirect hook => sub { push \@errs, [ \@_ ] };
-  {
-   ;
+  my \$hook;
+  BEGIN { \$hook = sub { push \@errs, [ \@_ ] } }
+  no strict;
+  no warnings;
+  no indirect hook => \$hook;
+  do {
 #line 1 "$file"
    $src
   }
- }
  WRAPPER
 
  {
   local ($@, *_);
   eval $wrapper; ## no critic
-  if ($@) {
+  if (my $err = $@) {
    require Carp;
-   Carp::confess("Couldn't compile the source wrapper: $@");
+   Carp::croak("Couldn't compile the source wrapper: $err");
   }
  }