From: Chris 'BinGOs' Williams Date: Sun, 6 Oct 2013 16:17:00 +0000 (+0100) Subject: disable warnings inside generated version sub (RT#89282) X-Git-Tag: v1.000019~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=72a35bb929a03a3264e4a56ce650b94c0a821aca;p=p5sagit%2FModule-Metadata.git disable warnings inside generated version sub (RT#89282) This shuts up warnings from modules like Log::Log4perl::Appender::Limit, which does: our $CVSVERSION = '$Revision: 1.7 $'; our ($VERSION) = ($CVSVERSION =~ /(\d+\.\d+)/); When only only the second line is eval-ed, that would cause an uninitialized value warning. --- diff --git a/Changes b/Changes index 91e2e5a..49afd5e 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,8 @@ Release history for Module-Metadata + - warnings now disabled inside during the evaluation of generated version + sub (BinGOs, RT#89282) + 1.000018 2013-09-11 - re-release of detainting fix without unstated non-core test dependencies diff --git a/lib/Module/Metadata.pm b/lib/Module/Metadata.pm index a92d05f..60f17e8 100644 --- a/lib/Module/Metadata.pm +++ b/lib/Module/Metadata.pm @@ -654,6 +654,7 @@ sub _evaluate_version_line { #; package Module::Metadata::_version::p$pn; use version; no strict; + no warnings; \$vsub = sub { local $sigil$var; diff --git a/t/metadata.t b/t/metadata.t index 20e6440..2c2eb9e 100644 --- a/t/metadata.t +++ b/t/metadata.t @@ -210,6 +210,12 @@ package Simple v1.2.3_4 { 1; } --- + '0' => <<'---', # set from separately-initialised variable +package Simple; + our $CVSVERSION = '$Revision: 1.7 $'; + our ($VERSION) = ($CVSVERSION =~ /(\d+\.\d+)/); +} +--- ); my %modules = reverse @modules;