++ed by:

4 PAUSE users

David Golden
and 2 contributors


Dist::Zilla::Plugin::RewriteVersion - Get and/or rewrite module versions to match distribution version


version 0.012


    # in your code, declare $VERSION like this:
    package Foo;
    our $VERSION = '1.23';

    # in your dist.ini


This module is both a VersionProvider and FileMunger.

This module finds a version in a specific format from the main module file and munges all gathered files to match. You can override the version found with the V environment variable, similar to Git::NextVersion, in which case all the gathered files have their $VERSION set to that value.

By default, versions must be "strict" -- decimal or 3+ part tuple with a leading "v". The allow_decimal_underscore option, if enabled, will also allow decimals to contain an underscore. All other version forms are not allowed, including: "v1.2", "1.2.3" and "v1.2.3_4".

Only the first occurrence of a $VERSION declaration in each file is relevant and/or affected (unless the "global" attribute is set and it must exactly match this regular expression:

    qr{^our \s+ \$VERSION \s* = \s* '$version::LAX'}mx

It must be at the start of a line and any trailing comments are deleted. The original may have double-quotes, but the re-written line will have single quotes.

The very restrictive regular expression format is intentional to avoid the various ways finding a version assignment could go wrong and to avoid using PPI, which has similar complexity issues.

For most modules, this should work just fine.

See BumpVersionAfterRelease for more details and usage examples.



Allows use of decimal versions with underscores. Default is false. (Version tuples with underscores are never allowed!)


If true, all occurrences of the version pattern will be replaced. Otherwise, only the first occurrence is replaced. Defaults to false.


If true, rely on some other mechanism for determining the "current" version instead of extracting it from the main_module. Defaults to false.

This enables hard-coding version = in dist.ini among other tricks.


If true, when the version is written, it will append a comment with the name of the tarball it comes from. This helps users track down the source of a module if its name doesn't match the tarball name. If the module is a TRIAL release, that is also in the comment. For example:

    our $VERSION = '0.010'; # from Foo-Bar-0.010.tar.gz
    our $VERSION = '0.011'; # TRIAL from Foo-Bar-0.011-TRIAL.tar.gz

This option defaults to false.



David Golden <dagolden@cpan.org>


This software is Copyright (c) 2014 by David Golden.

This is free software, licensed under:

  The Apache License, Version 2.0, January 2004