Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

using local $] = 5.008004;

by kamal (Sexton)
on Aug 21, 2013 at 03:12 UTC ( #1050274=perlquestion: print w/ replies, xml ) Need Help??
kamal has asked for the wisdom of the Perl Monks concerning the following question:

The temporary re-assignment of $] (Perl's version-number global) spoofs the module into thinking that the Perl binary has a lower version number than it actually does. Should we use this to get rid of perl -c errors ? or is there a better way. Here is an example use case for the same:
http://cpansearch.perl.org/src/RIBASUSHI/DBIx-Class-0.08250/lib/DBIx/C +lass/Carp.pm
see.... line
*DBIx::Class::_ENV_::BROKEN_NAMESPACE_CLEAN = ($] < 5.008005)
should test "($] < 5.008005)" in the DBIx::Class:Carp be extended to i +ncluding all of Perl 5.8

Comment on using local $] = 5.008004;
Select or Download Code
Re: using local $] = 5.008004;
by Anonymous Monk on Aug 21, 2013 at 03:34 UTC

    Should we use this to get rid of perl -c errors ?

    No

    or is there a better way... Here is an example use case for the same:

    Well, they don't try to redefine perl version. They detect a version nobody supports anymore, and disable a feature -- no faking perl version

    So, I'm not sure why you'd want to redefine $] and it doesn't seem like a solution to anything

      "Well, they don't try to redefine perl version. They detect a version nobody supports anymore, and disable a feature -- no faking perl version"

      I don't think kamal is claiming that the code posted does redefine the Perl version. I think he means that if you load DBIx::Class::Carp like this:

      BEGIN { local $] = 5.008004; require DBIx::Class::Carp; DBIx::Class::Carp->import; };

      ... you can trick DBIx::Class::Carp into thinking it's running on an older Perl version.

      And no, I wouldn't recommend doing that, because it'll be fragile. DBIx::Class::Carp is loaded in multiple places, it's only the version from the first time it's loaded that takes effect.

      package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1050274]
Approved by davido
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (8)
As of 2015-07-06 05:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (70 votes), past polls