in reply to using local $] = 5.008004;

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

Replies are listed 'Best First'.
Re^2: using local $] = 5.008004;
by tobyink (Canon) on Aug 21, 2013 at 11:01 UTC

    "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