=head1 NAME B - How (un)strict is your Perl code? =head1 SYNOPSIS strictv file ... =head1 DESCRIPTION Compile (but do not run) a Perl file using the C pragma. Only variables are checked. Input is a file (or several files). Output is to STDOUT. Example: strictv foo.pl =cut use warnings FATAL => 'all'; use strict; use List::Util qw(max); use English qw(-no_match_vars); for my $file (@ARGV) { $CHILD_ERROR = 0; my @errs = qx(perl -Mstrict=vars -c $file 2>&1); if ($CHILD_ERROR) { my %var; for (@errs) { if (/open perl script/) { print; } elsif (/ "([^"]+)" /x) { $var{$1}++; } } if (%var) { my $width = max(map {length} keys %var); for my $name (sort keys %var) { printf " %-${width}s : %d\n", $name, $var{$name}; } print "$file: ", scalar(keys %var), " variables\n"; } } }