Skip to content

Instantly share code, notes, and snippets.

@theory
Created July 17, 2017 18:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theory/52353b6d8b97b9d642c46df8a4dc95ef to your computer and use it in GitHub Desktop.
Save theory/52353b6d8b97b9d642c46df8a4dc95ef to your computer and use it in GitHub Desktop.
Simple script to update the version of a Perl distribution.
#!/usr/bin/perl -pi
BEGIN {
die "Usage: $0 version[, new_version]\n\n" unless @ARGV;
$old = shift;
$new = shift || sprintf('%.2f', $old + .01);
$dir = shift || '.';
@ARGV =
map { print; chomp; $_ }
grep !( /\.(?:svn|git)/ or /Change/ or /META\.yml/ or /Makefile\.PL/ or /blib/),
`grep -lr '\Q$old\E' $dir`;
}
s/((?:(?:\$|::|[.]|PGTAP_)VERSION\s*=?\s*|package\s+\S+)\s+'?)\Q$old\E('?)/${1}$new$2/g;
#s/(\s+version\s+)\Q$old\E$/$1$new/; # For README.
s/\b\Q$old\E$/$new/; # For README.pgtap.
__END__
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment