LanX has asked for the wisdom of the Perl Monks concerning the following question:
it's possible to alias a scalar to an element of a hash
DB<38> *y =\ $h{y} DB<39> $h{y}=666 DB<40> p $y 666 DB<41> $h{y}=42 DB<42> p $y 42
but I failed doing it the other way round. (i.e. $
Q1. Is it possible?
I could Tie::Hash the complete hash, but this would slow down all fetch operations on the hash, not only the aliased elements.
Q2. can I Tie::Scalar only a single element of a hash?
Thanks for insights! :)
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
FootballPerl is like chess, only without the dice
Sorry I'm stupid, my code already does what i wanted...
DB<53> $h{z}=111 DB<54> *z= \$h{z} DB<55> p $z 111 DB<56> $h{z}=222 DB<57> p $z 222 DB<58> $z=333 DB<59> p $h{z} 333
no not stupid, see my reply
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Aliasing hash-element and scalar?
by dave_the_m (Monsignor) on Sep 03, 2018 at 22:36 UTC | |
by LanX (Saint) on Sep 03, 2018 at 22:38 UTC | |
|
Re: Aliasing hash-element and scalar? (Tie::Scalar)
by LanX (Saint) on Sep 03, 2018 at 19:21 UTC | |
|
Re: Aliasing hash-element and scalar? (Not Solved Yet)
by LanX (Saint) on Sep 03, 2018 at 18:38 UTC | |
by Corion (Patriarch) on Sep 03, 2018 at 19:03 UTC | |
by LanX (Saint) on Sep 03, 2018 at 19:27 UTC |