1#!/usr/bin/perl -w
2
3#
4# Check the tree against missing VERSIONs.
5#
6# Originally by Larry Shatzer
7#
8
9use strict;
10use File::Find;
11
12find(
13     sub {
14	 return unless -f;
15	 if (/\.pm$/ && $File::Find::name !~ m:/t/:) { # pm but not in a test
16	     unless (parse_file($_)) {
17		 print "$File::Find::name\n";
18	     }
19	 }
20     }, @ARGV ? shift : ".");
21
22sub parse_file {
23    my $parsefile = shift;
24
25    my $result;
26
27    open(FH,'<',$parsefile) or warn "Could not open '$parsefile': $!";
28
29    my $inpod = 0;
30    while (<FH>) {
31	$inpod = /^=(?!cut)/ ? 1 : /^=cut/ ? 0 : $inpod;
32	next if $inpod || /^\s*\#/;
33	chomp;
34	next unless /([\$*])(([\w\:\']*)\bVERSION)\b.*\=/;
35	my $eval = qq{
36	    package ExtUtils::MakeMaker::_version;
37	    no strict;
38	    local $1$2;
39	    \$$2=undef; do {
40		$_
41	    }; \$$2
42	};
43	no warnings;
44	$result = eval($eval);
45	warn "Could not eval '$eval' in $parsefile: $@" if $@;
46	$result = "undef" unless defined $result;
47	last;
48    }
49    close FH;
50    return $result;
51}
52
53