Well, I know that Symbol::gensym keep a reference to an global GLOB at Symbol::GENx. What is not very good at POO. But for GLOB you need to keep it in some point!

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".


In reply to Re: Re: Perl Object as Hash, Array & Scalar in the same time! ( $O->{k} | $O->[0] | $O ) by gmpassos
in thread Perl Object as Hash, Array & Scalar in the same time! ( $O->{k} | $O->[0] | $O ) by gmpassos

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.