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. :)
|