-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathset_version.pl
51 lines (43 loc) · 1.07 KB
/
set_version.pl
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
#!perl
use File::Find;
use File::Copy;
BEGIN {
use Cwd;
our $dir = cwd;
}
use File::Spec;
use lib File::Spec->catfile( $dir, qw/Modules Tarp lib/ );
use strict;
use Tarp;
sub fix {
return if $_ eq "clean.pl";
return unless -f $_;
my ( $f, $t ) = ( $_, "__tmp_$_" );
open F, "<$f";
open F2, ">$t";
my $ch = 0;
my @from = ( qr/^Version (\d\.\d{1,})/,
qr/our \$VERSION = '(\d\.\d{1,})'/ );
my @to = ( "Version $Tarp::VERSION",
"our \$VERSION = '$Tarp::VERSION'" );
while ( <F> ) {
for my $i ( 0 .. 1 ) {
if ( $_ =~ $from[ $i ] ) {
# print "$f: $1 to $Tarp::VERSION\n";
s/$from[$i]/$to[$i]/;
$ch++;
}
}
print F2 $_;
}
close F2;
close F;
if ( $ch ) {
move $t, $f or die "Could not replace $t: $!";
print "$ch changes in $File::Find::name\n";
} else {
unlink $t or die "Could not remove $t: $!";
}
}
print "Setting version to $Tarp::VERSION\n";
find( \&fix, "." )