Even so, it's still a good idea to specify the version number of the Perl language against which you've written any program

That's a nice theory. And it sounds so reasonable.

It is too bad that the feature isn't actually implemented in a reasonable way for that use case. There is no "I wrote this on 5.10.1 so I can't be sure it will work on other versions" feature. There is only the "I'm damn sure that this will never, ever work on 5.10.0 or before and so any prior version will just tell you 'tough shit' with no real explanation" feature.

Since the 'require/use VERSION' feature has become increasingly misused, it would be nice if that feature became pluggable so, for example, an automated smoke test of 5.8.9 could arrange for "require 5.010.001;" (for example) in a module to be non-fatal in a deterministic way so that the module could actually be tested on 5.8.9 and the test results would actually record either "no, this actually works on 5.8.9; shame on the module author" or "one reason this doesn't work on 5.8.9 is that it uses //".

It is quite unfortunate that 'use VERSION' doesn't even allow the author to include a reason.

use 5.010 'uses //'; Perl v5.10.0 required (uses //) -- this is only v5.12.1, stopped. # No, this doesn't actually work.

Much better to just roll your own reasonable implementation

BEGIN { die "// not implemented in Perl $]\n" if $] < 5.010 }

Or even avoid the silly version number BS altogether:

BEGIN { die "// not implemented in Perl $]\n" if ! eval "undef() // 1" + }

Well, at least for cases where the existing diagnostic is worse (like this one):

perl5.8 -e'my $x= undef() // 1;' Search pattern not terminated ...

Or, for chromatic, it would be:

use v5.14 "Your Perl is old. Please don't waste my time. Go away until + you upgrade.";

...except that hard-coding v5.14 probably seems unfortunate to him. :)

- tye        


In reply to Re^2: Why version strings? (uh, no) by tye
in thread Why version strings? by gunzip

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.