in reply to Re: Perl Object as Hash, Array & Scalar in the same time! ( $O->{k} | $O->[0] | $O )
in thread Perl Object as Hash, Array & Scalar in the same time! ( $O->{k} | $O->[0] | $O )
To fix that the code need a DESTROY that destroy the GLOB too.
Note that you really need to put the different types inside the GLOB! You can't use a hash ref, since you want to do: $this->{key}, and this will go to get_hash(), and inside it you can't use $this->{key} or $this->[0], or you make an infinity loop of nothing. So, if you bless a hash, but make the access of it using overload you can't access again the hash, specially if you want to use overload for ARRAY access too!!! This is why I use GLOB, since is the only way that I found to access data inside the object wihtout use ways that are overloaded.
If you can find a way to make the same thing without Symbol::gensym (GLOB), please send! ;-P
Update:
From POD: "Symbol::gensym creates an anonymous glob and returns a reference to it"!
The GLOB is already anonymous! Test to creat multiples GLOB from gensym(), you can see that is always *Symbol::GEN0.
Graciliano M. P.
"The creativity is the expression of the liberty".
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Perl Object as Hash, Array & Scalar in the same time! ( $O->{k} | $O->[0] | $O )
by diotalevi (Canon) on May 10, 2003 at 02:43 UTC | |
by gmpassos (Priest) on May 10, 2003 at 02:56 UTC |