File: push_ver

package info (click to toggle)
libsnmp-info-perl 2.01-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 1,352 kB
  • ctags: 850
  • sloc: perl: 14,530; makefile: 15; sh: 1
file content (46 lines) | stat: -rwxr-xr-x 828 bytes parent folder | download
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
#!/usr/bin/perl -w
# $Id: push_ver,v 1.1 2009/06/12 21:59:05 maxbaker Exp $

use File::Glob qw/bsd_glob/;

my @pms = glob_rec("../Info");

$new_version = shift @ARGV || '2.01';

foreach my $p (@pms) {
    print "$p\n";

    rename($p,"$p.orig");
    open (O,"<$p.orig") or die;
    open (P,">$p") or die "Can't open $p for write. $!\n";

    while (<O>) {
        s/^\s*\$VERSION\s+=\s*'[^']+'\s*;/\$VERSION = '$new_version';/;
        print P;
    }

    close O;
    close P or die "Can't write $p. $!\n";
    #last;
}

sub glob_rec {
    my $dir = shift;

    my @files = bsd_glob("$dir/*");

    my @pms;

    foreach my $f (@files) {
        next if $f eq '\.$';
        
        if (-d $f) {
            push @pms, glob_rec($f);
            next;
        }

        push @pms,$f if $f =~ /.pm$/;
    }

    return @pms;
}