fix 5.16 crash due to qw() list being readonly
[p5sagit/strictures.git] / lib / strictures.pm
index 714faaa..21bd8b4 100644 (file)
@@ -46,13 +46,16 @@ sub import {
     $extra_load_states ||= do {
 
       my (%rv, @failed);
-      for my $mod (qw(indirect multidimensional bareword::filehandles)) {
+      foreach my $mod (qw(indirect multidimensional bareword::filehandles)) {
         eval "require $mod; \$rv{'$mod'} = 1;" or do {
           push @failed, $mod;
 
           # courtesy of the 5.8 require bug
-          $mod =~ s|::|/|g;
-          delete $INC{"$mod.pm"};
+          # (we do a copy because 5.16.2 at least uses the same read-only
+          # scalars for the qw() list and it doesn't seem worth a $^V check)
+
+          (my $file = $mod) =~ s|::|/|g;
+          delete $INC{"${file}.pm"};
         };
       }