Add aliases for several version numbers in Module::CoreList
authorJohn Peacock via RT <bug-Module-CoreList@rt.cpan.org>
Sun, 18 Jan 2009 16:41:20 +0000 (17:41 +0100)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Sun, 18 Jan 2009 16:41:20 +0000 (17:41 +0100)
[rt.cpan.org #41827] Can't use $] to select Perl version

The %version hash is initialized with bare numbers for each Perl
version.  Unfortunately, the tokenizer will have already eaten trailing
zeros before the fat comma operator is seen, hence the normal
stringification behavior won't have the appropriate affect.

This can be seen by doing something simple like:

perl5.10.0 -MModule::CoreList -e \
'print keys(%{$Module::CoreList::version{$]}})'

which will be empty, since $] is a string not a number.  Using $]+0 (to
force numification) will display all of the modules released with 5.10.0.

Either 5.000 and 5.010000 need to be quoted in the %version
initialization or an alias be created, so either 5.01 or "5.010000" (and
hence $]) will work.  This latter is probably better to use, trivial patch

(rgs: I added aliases for the %released and %patchlevel hashes too.)

lib/Module/CoreList.pm

index c68d81f..7b117f3 100644 (file)
@@ -9076,5 +9076,16 @@ for my $version ( sort { $a <=> $b } keys %released ) {
     },
 );
 
+# Create aliases with trailing zeros for $] use
+
+$released{'5.000'} = $released{5};
+$released{'5.010000'} = $released{5.01};
+
+$patchlevel{'5.000'} = $patchlevel{5};
+$patchlevel{'5.010000'} = $patchlevel{5.01};
+
+$version{'5.000'} = $version{5};
+$version{'5.010000'} = $version{5.01};
+
 1;
 __END__