Subject: | Version parsing confused by sub version {} |
Date: | Fri, 16 Nov 2007 12:49:44 -0800 |
To: | List - Module-Build <module-build [...] perl.org>, bug-Module-Build [...] rt.cpan.org |
From: | Michael G Schwern <schwern [...] pobox.com> |
A bug in MakeMaker's parse_version() was found recently. Module::Build has
the same bug.
https://rt.cpan.org/Ticket/Display.html?id=30747
It's reproducible by getting the version from a module like this:
$VERSION = 1.23; sub version { $VERSION }
and then this:
use version; $VERSION = version->new(2.34);
The version() routine pollutes the namespace in which the $VERSION code is
evaled. It thinks version->new() is version()->new() calling the polluting
version() routine. MakeMaker fixed it by deleting any version() routines from
the symbol table before trying to eval the $VERSION code.
Here's code to reproduce:
$ cat Version_Sub.pm
package Version_Sub;
$VERSION = 1.23; sub version { $VERSION }
1;
$ cat Uses_version.pm
package Uses_version.pm;
use version; $VERSION = version->new(2.34);
1;
$ perl -wle 'use aliased "Module::Build::ModuleInfo"; print
ModuleInfo->new_from_file("Version_Sub.pm")->version; print
ModuleInfo->new_from_file("Uses_version.pm")->version'
1.23
Can't call method "new" without a package or object reference at (eval 10)
line 8, <GEN1> line 3.
--
Insulting our readers is part of our business model.
http://somethingpositive.net/sp07122005.shtml