our $VERSION = "0.001"; $VERSION = eval $VERSION;

The thing I don't like about this is that (depending upon the original string), you might find that, after the eval is done, "$VERSION" ne <original_string>
No such problem with "0.001", but consider this simple script:
use strict; use warnings; my $str = "2.30"; our $VERSION = $str; $VERSION = eval $VERSION; print "WTF\n" if $VERSION ne $str;
That outputs "WTF".
That is, having assigned the string "2.30" to $VERSION, the eval forces $VERSION into a state where it stringifies to something other than "2.30" - namely to "2.3".

It's probably of little importance, but I found it annoying enough to immediately replace all occurrences of eval $VERSION in my .pm files with #eval $VERSION
I've no regrets about having done that, yet.

Notably, with the eval removed, we can then perform both numeric and string comparisons reliably:
use strict; use warnings; my $str = "2.30"; our $VERSION = $str; print "OK 1\n" if $VERSION == 2.3; print "OK 2\n" if $VERSION == $str; print "OK 3\n" if $VERSION eq $str; print $VERSION, " ", $str, "\n"; print "$VERSION $str\n"; __END_ outputs: OK 1 OK 2 OK 3 2.30 2.30 2.30 2.30
I find that saner and preferable ... though I now always avoid using version strings that terminate with one or more zeros ... just in case ;-)

Cheers,
Rob

In reply to Re^6: Why eval $version? by syphilis
in thread Why eval $version? by Aldebaran

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.