develooper Front page | perl.perl5.porters | Postings from July 2001

Re: [Help] Salvage the Array Hash Monster.

Thread Previous | Thread Next
From:
Arthur Bergman
Date:
July 27, 2001 00:03
Subject:
Re: [Help] Salvage the Array Hash Monster.
Message ID:
B786DED3.2880%arthur@contiller.se
01-07-27 05.38, skrev Sam Tregar på sam@tregar.com följande:

> That's what tie is for.  Your object can store the two tied objects - the
> array tie and the hash tie.  Then you can dispatch to the appropriate
> object when ->[] or ->{} is called.

I seee no reason why the following shouldn't work.

$foo = bless {},"myclass";
my (%data, @data);

tie %data,'myclass',$foo;
tie @data,'myclass',$foo;

sub TIEARRAY {
    return $_[1];
}

sub TIEHASH {
    return $_[1];  
}

Now they are both tied to $foo.

On another note, why can't I get to the value I am being tied to from inside
TIE*, do I realy need to traverse the stack to find that value?

-- 
Arthur


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About