forked from PDLPorters/PDL-Graphics-Prima
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate-versions.pl
35 lines (32 loc) · 883 Bytes
/
update-versions.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
use strict;
use warnings;
# Propogates the version string in lib/PDL/Graphics/Prima.pm to the version
# strings in the other modules.
open my $in_fh, '<', 'lib/PDL/Graphics/Prima.pm';
# Find the version string
my $version;
while(<$in_fh>) {
if (/^our \$VERSION = (\d\.\d\d.{4})/) {
$version = $1;
last;
}
}
defined $version or die "Unable to extract the version!!!\n";
close $in_fh;
# OK, now run through all the module files
for my $module_filename (glob 'lib/PDL/Graphics/Prima/*.pm') {
next if $module_filename =~ /Internals/;
open my $out_fh, '+<', $module_filename;
while (my $line = <$out_fh>) {
if ($line =~ /\$VERSION = (.{8})/) {
if ($1 ne $version) {
print "Updating $module_filename\n";
# reposition to the start of the line
seek $out_fh, -length($line), 1;
print $out_fh "our \$VERSION = $version";
}
last;
}
}
close $out_fh;
}