Re: tied hash
- From: anno4000@xxxxxxxxxxxxxxxxxxxxxxx (Anno Siegel)
- Date: 28 Jul 2005 10:46:41 GMT
Konrad Eisele <konrad@xxxxxxxxxxx> wrote in comp.lang.perl.misc:
> I have a tied hash, say %a. On a tied 'STORE' I want to get the return
> values of the STORE function. is that possible? a naive aproach would be
> @a = ($a{'key'} = 'value'); however this returns still the tied FETCH
> of $a{'key'}. How do i have to reorder the expression??
>
> -- Konrad
>
>
>
>
> %a = ();
> tie %a,'Ta';
> @a = ($a{'key'} = 'value');
When this happens, @Ta::ISA is not yet set.
> package Ta;
> use Tie::Hash;
> @ISA = qw(Tie::StdHash);
This happens too late. Wrap "BEGIN {}" around it.
> sub STORE {
> return [1,2,3];
> }
Your example program doesn't use your STORE method.
But even if it did, what is returned by an assignment is always the
variable on the left hand side (with the new value already in it).
If that happens to be tied, or, in your example, happens to be a value
in a tied hash, that doesn't change that fact. The value you see will
be the value stored (as read back by READ), no matter what STORE returns.
Anno
--
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
.
- References:
- tied hash
- From: Konrad Eisele
- tied hash
- Prev by Date: true false ? : expression thingy
- Next by Date: Re: true false ? : expression thingy
- Previous by thread: Re: tied hash
- Next by thread: Help with split using multiple delimiters
- Index(es):
Relevant Pages
|
|