After a romp through some SuperSearch results (and a read through Perl Best Practices), I wound up coding my $VERSION like this:

use vars qw( $VERSION ); use version; $VERSION = qv( (qw$Revision: 1.1 $)[-1] );

...where $Revision: 1.1 $ is something that's maintained for me by the revision control system I'm using.

Recently, I decided to start using git for revision control (having written some Perl to replay my old history into it). Since git is distributed, it really can't give me revision numbers in files like CVS can, so I'm looking for a new way forward.

I'm far too lazy to remember to update one of those numbers every time I touch a module, but I would like them to stay up-to-date. How do others handle this? How do you get a worthwhile version number into your programs and modules without any discipline or other noticeable effort?

The only solution I've thought of is a local commit script. It would determine which files have changed since the last commit and update their version numbers before running a git commit. This wouldn't be too hard to implement, and the habit of using it wouldn't be hard to form. Even so, I'm wondering if there is an even better way. Can I slip in another few lines in place of my $Revision$ hack and get what I want?

All your wisdom will be greatly appreciated.


In reply to Best Practice for automatic version numbers? by kyle

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.