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

A question, why doesn't $this get overwritten in the symbol table?

*$this = \$scalar ; *$this = [qw(a b c)] ; *$this = {A => 10 , B => 20 , C => 30} ;
I guess the prepending of '*' is causing a separate entry to be written out for each data type?

Also, what is this for? Typically in OOP you really don't want other code accessing data members directly, but rather through methods. It is neat though :^)


"The dead do not recognize context" -- Kai, Lexx

Replies are listed 'Best First'.
Re: Re: Perl Object as Hash, Array & Scalar in the same time! ( $O->{k} | $O->[0] | $O )
by PodMaster (Abbot) on May 09, 2003 at 22:30 UTC
    read `perldoc perldata' (the "Typeglobs and Filehandles" section), and `perldoc perlmod' (the "Symbol Tables" section).


    MJD says you can't just make shit up and expect the computer to know what you mean, retardo!
    I run a Win32 PPM repository for perl 5.6x+5.8x. I take requests.
    ** The Third rule of perl club is a statement of fact: pod is sexy.

Re: Re: Perl Object as Hash, Array & Scalar in the same time! ( $O->{k} | $O->[0] | $O )
by gmpassos (Priest) on May 10, 2003 at 01:20 UTC
    $this is a GLOB ref (see Symbol::gensym). Inside it the 3 types are saved for future access.

    Why I need this?! Well, I need to have the 3 types for a new way to access XML/HTML data. Scalar for the content, Array to index tags with the same name and in the same sub-tree, Hash to return an argument or other tree object. Is hard to explain all here, but I will announce here the module when it's done.

    Graciliano M. P.
    "The creativity is the expression of the liberty".