File: checkVERSION.pl

package info (click to toggle)
perl 5.24.1-3+deb9u5
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 103,716 kB
  • sloc: perl: 559,611; ansic: 293,886; sh: 67,316; pascal: 7,632; cpp: 3,895; makefile: 2,436; xml: 2,410; yacc: 989; sed: 6; lisp: 1
file content (52 lines) | stat: -rwxr-xr-x 975 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/perl -w

#
# Check the tree against missing VERSIONs.
#
# Originally by Larry Shatzer
#

use strict;
use File::Find;

find(
     sub {
	 return unless -f;
	 if (/\.pm$/ && $File::Find::name !~ m:/t/:) { # pm but not in a test
	     unless (parse_file($_)) {
		 print "$File::Find::name\n";
	     }
	 }
     }, @ARGV ? shift : ".");

sub parse_file {
    my $parsefile = shift;

    my $result;

    open(FH,$parsefile) or warn "Could not open '$parsefile': $!";

    my $inpod = 0;
    while (<FH>) {
	$inpod = /^=(?!cut)/ ? 1 : /^=cut/ ? 0 : $inpod;
	next if $inpod || /^\s*\#/;
	chomp;
	next unless /([\$*])(([\w\:\']*)\bVERSION)\b.*\=/;
	my $eval = qq{
	    package ExtUtils::MakeMaker::_version;
	    no strict;
	    local $1$2;
	    \$$2=undef; do {
		$_
	    }; \$$2
	};
	no warnings;
	$result = eval($eval);
	warn "Could not eval '$eval' in $parsefile: $@" if $@;
	$result = "undef" unless defined $result;
	last;
    }
    close FH;
    return $result;
}