develooper Front page | perl.perl5.porters | Postings from January 2008

5.10 and v-string portability warning

Thread Next
From:
Peter Scott
Date:
January 5, 2008 02:10
Subject:
5.10 and v-string portability warning
Message ID:
pan.2008.01.05.10.10.35.290566@PSDT.com
This may bite a number of people who get 5.10.  A test in an app started
breaking after 5.8.8 -> 5.10.0.  Turned out that the test included
Test::NoWarnings and the test was using a module that did "require 5.6.0",
thus resulting in (from perldiag):

       v-string in use/require is non-portable
           (W portable) The use of v-strings is non-portable to older,
           pre-5.6, Perls.  If you want your scripts to be backward portable,
           use the floating point version number: for example, instead of "use
           5.6.1" say "use 5.006_001". This of course won't make older
           Perls suddenly start understanding newer features, but at least
           they will show a sensible error message indicating the required
           minimum version.

           This warning is suppressed if the "use 5.x.y" is preceded by a "use
           5.006" (see "use VERSION" in "use" in perlfunc).

Okay.  Unfortunately, suppressing this warning using the advertised
mechanism appears to work only when the 'use 5.006' [1] is within the
lexical scope of the 'use 5.x.y'  But this is a CPAN module, and not mine,
so I'm not crazy about modifying it.  And even though the module doesn't
"use warnings", Test::Harness::runtests invokes the test with '-w', and
that's hardcoded in a way that I can't see how to defeat without making a
custom/subclassed Test::Harness, because PERL5OPT doesn't allow -X.  Ouch.

Even hauling Test::NoWarnings out of this one test is a pain because it's
embedded in a common module for testing the app, so my fix so far is to
import and call clear_warnings from Test::NoWarnings after the use_ok. 
That aside, anyone with a program with -w on the shebang will get a new
warning when using a module that offends similarly [2]; should the
diagnostic message be changed to suggest changing -w to "use warnings"?
 

[1] BTW, it needs to be 'require 5.006' if the offending line is 'require
5.x.y', might want to mention that.
[2] About 300 according to Google code search: http://tinyurl.com/2h4vdw

-- 
Peter Scott


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About