6 use Support::CanonialGlobals ();
 
   8 my (@globals, $testcount);
 
  11   @globals = map { s/[^a-z_]//g; $_ } @Support::CanonialGlobals::globals;
 
  12   $testcount = scalar(@Support::Files::testitems);
 
  16 use Test::More tests => $testcount;
 
  18 # Capture the TESTOUT from Test::More or Test::Builder for printing errors.
 
  19 # This will handle verbosity for us automatically.
 
  22     local $^W = 0;  # Don't complain about non-existent filehandles
 
  23     if (-e \*Test::More::TESTOUT) {
 
  24         $fh = \*Test::More::TESTOUT;
 
  25     } elsif (-e \*Test::Builder::TESTOUT) {
 
  26         $fh = \*Test::Builder::TESTOUT;
 
  32 my @testitems = @Support::Files::testitems;
 
  34 # at last, here we actually run the test...
 
  35 my $evilwordsregexp = join('|', @globals);
 
  37 foreach my $file (@testitems) {
 
  38     $file =~ s/\s.*$//; # nuke everything after the first space (#comment)
 
  39     next if (!$file); # skip null entries
 
  41     if (open (FILE, $file)) { # open the file for reading
 
  45         while (my $file_line = <FILE>) { # and go through the file line by line
 
  46             if ($file_line =~ /([\$%@](?:main)?::(?!$evilwordsregexp)\w+\b)/i) { # found an evil word
 
  55             ok(0,"$file: found UNREGISTERED GLOBAL $found_word --WARNING");
 
  60         ok(0,"could not open $file for globals check --WARNING");