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

Replies are listed 'Best First'.
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