Michael G Schwern via RT wrote:
v1.2.3 style version strings are being "phased out" and should be
replaced by the various options presented by version.pm.
Well, no, not exactly. v1.2.3 versions are likely to be the preferred format
for Perl6 (AIUI), but the leading 'v' won't be a v-string any longer but rather
a fullblown version number. It's true that the version.pm module will permit
compatibility for older Perl's, but the following are completely equivalent
(under v5.9.3+):
package oldstyle;
use version;
our $VERSION = version->new(v1.2.3);
package newtyle;
our $VERSION = v1.2.3;
OK, I'm fibbing a little in that the first package will have a version object
and the second will not (although I have a patch to do so), but both of them
will emerge from UNIVERSAL::VERSION completely identically, i.e. as 1.002003).
See below for why that distinction is important.
All the above now works in 5.8.6 with the exception of the final
"Argument "^AP" isn't numeric" warning which is still there. As version
strings are going bye-bye will that ever be fixed?
It shouldn't be fixed, because the naive tests Tom was making in the second half
of the bug were based on a flawed understanding of how the UNIVERSAL::VERSION
sub operated then or now. When called as a class method like
IO::File::->VERSION, UNIVERSAL::VERSION merely returns the contents of the
package $VERSION scalar. As such, any special handling due to v-string, etc,
doesn't happen at all. And so there is no way that a bare == comparison will
"know" anything about how to handle version comparisons vs. v-strings.
The only way to see whether the v-string versions are handled properly in Perl
5.8.1+ is to 'use package v1' (and hence why all of the first half of the bug
report now work fine). It is not currently possible to compare a version number
to a bare v-string and unless I make $VERSION a magical scalar to automatically
upgrade to version objects (a patch I currently have working, BTW), it won't
ever be possible in the general case.
With the patch I have to automatically upgrade the package $VERSION scalar to a
version object, the following becomes true:
$ LD_LIBRARY_PATH=$PWD ./perl -Ilib -MIO::File -we 'print ref
$IO::File::VERSION'
version
$ LD_LIBRARY_PATH=$PWD ./perl -Ilib -MIO::File -we 'printf "%d\n",
$IO::File::VERSION == v1.120'
1
$ LD_LIBRARY_PATH=$PWD ./perl -Ilib -MIO::File -we 'printf "%d\n",
$IO::File::VERSION == v1.121'
0
but when called as a package method, UNIVERSAL::VERSION returns the *numified*
representation of the underlying version object, not the version object itself,
so this will still warn:
$ LD_LIBRARY_PATH=$PWD ./perl -Ilib -MIO::File -we 'printf "%d\n",
IO::File::->VERSION == v1.120'
Argument "^Ax" isn't numeric in numeric eq (==) at -e line 1.
0
I have delayed closing this ticket mostly through inertia. With this
explanation appended, it can now be safely closed I think.
John
--
John Peacock
Director of Information Research and Technology
Rowman & Littlefield Publishing Group
4720 Boston Way
Lanham, MD 20706
301-459-3366 x.5010
fax 301-429-5747