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.

In reply to Do you ever forget to use the strictures? by tphyahoo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.