http://qs1969.pair.com?node_id=487760

I do. Lots of pls and pms and .ts out there and sometimes I just... forget. And ugly things happen.

So, here's a sanity check I will be running every now and then when weirdness creeps into my life. Put it into the top of any directory, and it spits out the perl files where you forgot to use strict or use warnings.

use strict; use warnings; use File::Find; use File::Slurp; my @starters = @ARGV ? @ARGV : qw(.); my @files; @ARGV = (); find sub { push @files, $File::Find::name if /\.(pl|pm)$/; # or whatever cond +ition here }, @starters; print "Perl files that don't use the stricutres\n"; foreach my $file (@files) { my $text = read_file( $file ) ; print "$file\n" unless ( $text =~ /use warnings;/ && $text =~ /use + strict;/ ) ; }
Output:
C:\thomasdata\thomasprojects\fixHtml\fix_fonts>perl sanitycheck.t Perl files that don't use the stricutres ./modules/Htmlripper/Fixbeginningincludes.pm ./modules/Htmlripper/Fixmaintableincludes.pm ./modules/Htmlripper/Fixtidy.pm ./modules/Htmlripper/Fixtocanonical.pm ./modules/Htmlripper/Regex/Changeincludes.pm ./modules/Htmlripper/Regex/Fixdoctype.pm ./modules/Htmlripper/Regex/Fixwhitespace.pm ./modules/Htmlripper/Regex/Striphaupttable.pm ./modules/Htmlripper/Regex/Stripmenu.pm C:\thomasdata\thomasprojects\fixHtml\fix_fonts>
UPDATE: turned off the i flags, as ysth suggested.