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