From ff7aebaa0ec36e30b44da8f12b8695b0520d5eb9 Mon Sep 17 00:00:00 2001 From: Daniel Nichter Date: Wed, 8 Aug 2012 15:23:52 -0600 Subject: [PATCH] Coerce PERL_VERSION with %vd to fix 5.8. --- lib/VersionCheck.pm | 8 ++++++++ t/lib/VersionCheck.t | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/lib/VersionCheck.pm b/lib/VersionCheck.pm index 8f5fc5cc..ad0f059c 100644 --- a/lib/VersionCheck.pm +++ b/lib/VersionCheck.pm @@ -171,6 +171,14 @@ sub get_perl_variable { my $item = $args{item}; return unless $item; + # Can't just stringify $PERL_VERSION because on 5.8 it doesn't work. + # So %vd coerces the version into a string on 5.8+. + if ( $item->{item} eq 'Perl' ) { + my $version = sprintf '%vd', $PERL_VERSION; + PTDEBUG && _d('Perl version', $version); + return $version; + } + # If there's a var, then its an explicit Perl variable name to get, # else the item name is an implicity Perl module name to which we # append ::VERSION to get the module's version. diff --git a/t/lib/VersionCheck.t b/t/lib/VersionCheck.t index 4635e4ee..5f3e8e15 100644 --- a/t/lib/VersionCheck.t +++ b/t/lib/VersionCheck.t @@ -46,6 +46,16 @@ sub test_v { "$args{name} versions" ); + # Perl 5.8 $^V/$PERL_VERSION is borked, make sure + # the module is coping with it. + if ( $items->{Perl} ) { + like( + $versions->{Perl}, + q/\d+\.\d+.\d+/, + "Perl version looks like a version" + ); + } + return; }