in reply to Re: Make hash key an alias
in thread Make hash key an alias
Well, the way I read this its actually wrong. (UPDATE: and calin said as much, although in a way that may not be immediately apparent to readers unfamiliar with Lexical::Alias, so I still feel this node is worthy, if only to expand on what is happening here.) In this you arent making $h{key} an alias to $s. You are making $s be an alias to $h{key}. Not the same thing. Use Array::RefElem and you dont have this problem, and can do it with either lexicals or globals. (Making the composite type contain an alias to an arbitrary Scalar that is.)
use Lexical::Alias qw(alias_r); my ($s, %h); print '$s:',\$s, "\n", '$h{key}:',\$h{key}, "\n"; print "---\n"; alias_r \$h{key}, \$s; print '$s:',\$s, "\n", '$h{key}:',\$h{key}, "\n"; __END__ $s:SCALAR(0x1ac2430) $h{key}:SCALAR(0x1acefd4) --- $s:SCALAR(0x1acefd4) $h{key}:SCALAR(0x1acefd4)
Come to think of it IMO its ridiculous all these different modules with weirdo names having alias related tools in them. I think this calls for a consolodation release with them all in one place... (broquaint are you listening?)
First they ignore you, then they laugh at you, then they fight you, then you win.
-- Gandhi
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Re: Make hash key an alias
by calin (Deacon) on Nov 18, 2003 at 16:31 UTC | |
by demerphq (Chancellor) on Nov 18, 2003 at 16:34 UTC |