Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re^2: Transitive aliases

by JadeNB (Chaplain)
on Dec 28, 2009 at 03:18 UTC ( #814570=note: print w/replies, xml ) Need Help??

in reply to Re: Transitive aliases
in thread Transitive aliases

This is a good idea, although I think I may have made the problem statement over-specific—I'd really like to be able to handle any circular reference, not just a reference to an array of several copies of a single variable. Thus, maybe the appropriate thing to do would be

sub switch_var { tie $_[2], to => $_[1]; } package to; sub TIESCALAR { bless \$_[1] => $_[0]; } sub STORE { ${$_[0]} = $_[1] } sub FETCH { ${$_[0]} }
(There's some package out there already on CPAN that uses the to package for similar effect, but I can't find it. UPDATE: It's Tie::Util. Also, the functionality that I've described is quite similar—indeed, maybe identical—to that provided by Tie::Coupler.)

I wonder if there's a non-tie-based solution? I might have to do switch_var several times, and going through many ties could get quite slow.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://814570]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2021-04-16 10:43 GMT
Find Nodes?
    Voting Booth?

    No recent polls found