Is any one of these preferable?
By all means, do whatever you find most preferable. You're likely the one who's going to deal with the code most of the time (and even then, you're likely won't change anything other than the version number itself). And anyone else isn't going to get confused when seeing a line that assigns a number to a variable called VERSION. It's obvious what it's for, regardless of the syntax you're using.

One point though, $main::VERSION sets the variable in the package main. I presume you're using main just as an example - normally you want to use the name of the package instead of main. Otherwise, Exporter cannot do its job.

I prefer the our $VERSION = "..."; style, but I can happily work with the other styles. I would use use vars '$VERSION'; $VERSION = "..."; if I had to create a new module that needs to be able to run on 5.005, but it has been many years since I created a module with such a restriction, and I doubt I will write another such module in the future.


In reply to Re: use vars vs our vs $main:: for $VERSION by JavaFan
in thread use vars vs our vs $main:: for $VERSION by bv

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.