Skip to content

Instantly share code, notes, and snippets.

@mattdees
Created June 19, 2012 17:01
Show Gist options
  • Save mattdees/2955290 to your computer and use it in GitHub Desktop.
Save mattdees/2955290 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
my $input = $ARGV[0];
if ( !-e $input ) {
die "File not found";
}
if ( -d $input) {
die "Path is a directory";
}
print "Checking strict for $input\n";
system ('perl', '-Mstrict', '-X', '-c', $input);
print "\nChecking warnings for $input\n";
if ( $input =~ /\.pm$/ ) {
my $namespace = $input;
$namespace =~ s{\.pm$}{}i;
$namespace =~ s{^/+}{};
$namespace =~ s{/}{::}g;
my $use_string = "use $namespace (); print STDERR \"$input syntax OK\"";
# print "Detected module, namespace is $namespace\nexecuting the following line to validate:\n$use_string\n";
system ('perl', '-w', '-e', "$use_string");
print "\n";
}
else {
system ('perl', '-w', '-c', $input);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment