Just a Theory

By David E. Wheeler

How I Increment Module Version Numbers

Here’s how I quickly increment version numbers in my modules. I call this script reversion:

#!/usr/bin/perl -w

use strict;

unless (@ARGV) {
    print "  Usage: $0 version\n\n";
    exit;
}

my $old = shift;
my $new = $old + .01;
my $dir = shift || '.';

system qq{grep -lr '\Q$old\E' $dir }
  . '| grep -v \\.svn '
  . '| grep -v Changes '
  . '| grep -v META\\.yml '
  . "| xargs $^X -i -pe \""
  . qq{print STDERR \\\$ARGV[0], \\\$/ unless \\\$::seen{\\\$ARGV[0]}++;}
  . qq{s/(\\\$VERSION\\s*=?\\s*'?)\Q$old\E('?)/\\\${1}$new\\\$2/g"};

__END__

Enjoy!

Looking for the comments? Try the old layout.

More about…