note
cavac
<p>For me, updating the manifest is pretty much standard procedure whenever i add or remove files from one of my projects. As for updating version numbers and stuff, i also have scripts for that.</p>
<p>setversion.pl:<br/></p>
<readmore>
<p><code>#!/usr/bin/env perl
#---AUTOPRAGMASTART---
use 5.020;
use strict;
use warnings;
use diagnostics;
use mro 'c3';
use English;
use Carp;
our $VERSION = 18;
use autodie qw( close );
use Array::Contains;
use utf8;
use Encode qw(is_utf8 encode_utf8 decode_utf8);
#---AUTOPRAGMAEND---
# PAGECAMEL (C) 2008-2020 Rene Schickbauer
# Developed under Artistic license
my $newversion = shift @ARGV || "???";
if($newversion eq "???") {
print "Usage: perl devscripts/setversion.pl 9.87\n";
exit(0);
}
print "Searching files...\n";
my @files = (find_pm('lib'), find_pm('devscripts'), find_pm('example'));
print "Changing files:\n";
foreach my $file (@files) {
print "Editing $file...\n";
my @lines;
open(my $ifh, "<", $file) or die($ERRNO);
@lines = <$ifh>;
close $ifh;
open(my $ofh, ">", $file) or die($ERRNO);
foreach my $line (@lines) {
$line =~ s/VERSION = [\d\.]+/VERSION = $newversion/g;
print $ofh $line;
}
close $ofh;
}
print "Done.\n";
exit(0);
sub find_pm {
my ($workDir) = @_;
my @files;
opendir(my $dfh, $workDir) or die($ERRNO);
while((my $fname = readdir($dfh))) {
next if($fname eq "." || $fname eq ".." || $fname eq ".hg");
$fname = $workDir . "/" . $fname;
if(-d $fname) {
push @files, find_pm($fname);
} elsif($fname =~ /\.p[lm]$/i && -f $fname) {
push @files, $fname;
}
}
closedir($dfh);
return @files;
}</code>
</p>
</readmore>
<p>It's probably not the most efficient of scripts, but it does the job for me in a lot of open source and closed source projects. This one is taken directly from my <a href="https://cavac.at/public/mercurial/Net-Clacks">Net::Clacks repository</a>. The script is in the "devscripts" directory, which also holds such gems as "fixpragmas.pl" that allows me to change the standard pragmas for all *.pm files in a project all in one go.</p>
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-890813">
<code>perl -e 'use Crypt::Digest::SHA256 qw[sha256_hex]; print substr(sha256_hex("the Answer To Life, The Universe And Everything"), 6, 2), "\n";'</code>
</div></div>
11138164
11138191