rinceWind has asked for the wisdom of the Perl Monks concerning the following question:

Dipping into Damian's "Perl Best Practices", I learn about a new module Data::Alias. I find some instances where I want to use it, revisiting some of my code - reapplying array subscripts and hash keys, especially when needed as an lvalue.

But, I come to install the module and find that it needs perl 5.8.1, and I'm trying to install it on 5.6.1. Not to be deterred, I have a peep at the source code, spotting the line

use 5.008001;
I try commenting this line out of the module and Makefile.PL, but to no avail. The module contains some very hairy XS, and refuses to compile. So, the use statement was not just boilerplate from h2xs.

Hunting around on CPAN, I find another module Lexical::Alias, which needs 5.8.0, which leads me to Devel::LexAlias (listed under see also). Devel::LexAlias only needs 5.005! Data::Alias has a much nicer API though.

Have I missed something? Is there some convenient piece of internals that enables lexical aliasing, that came in with 5.8? Is it worth building a common wrapper over either Devel::LexAlias or Data::Alias based on the perl version?

--

Oh Lord, won’t you burn me a Knoppix CD ?
My friends all rate Windows, I must disagree.
Your powers of persuasion will set them all free,
So oh Lord, won’t you burn me a Knoppix CD ?
(Missquoting Janis Joplin)

Replies are listed 'Best First'.
Re: Lexical aliasing for perl versions prior to 5.8
by xdg (Monsignor) on Dec 07, 2005 at 15:15 UTC

    Lexical::Alias doesn't need 5.8 -- but one of the functions it offers doesn't work under 5.8. The synopsis is confusing. You can't use plain alias before 5.8, but you can use alias_s, alias_s, alias_a, alias_h and alias_r.

    -xdg

    Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.