Re: tied hash



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



Relevant Pages

  • Re: Expensive kitchen stuff
    ... My latest purchase was an inexpensive on-sale Cusinart (bottom of the ... One of the reasons I bought it was, it was a 14-inch pan -- and I thought ... a look at www.fantes.com Now when have I ever been in a store like that! ... Dee Dee ...
    (rec.food.cooking)
  • Re: Numerous oddities when launching or installing software
    ... My reply is at the bottom of your sent message: ... once again for your feedback!! ... > It's off to the store today to buy a copy of XP Pro. ... "My mind rebels at stagnation. ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: Geek Yard Sale
    ... contractors coming to do work so rooms have to ... There is an outfit called PODS which will allow you to store things ... the broken "Reply" link at the bottom of the article. ...
    (comp.os.linux.misc)
  • Re: Where is everyone?
    ... working as a journeyman checker in a really fast paced grocery store ... bread and some lunch meat. ... fresh loaf of bread, before I pulled my hand away, I jabbed the bottom ...
    (rec.pets.cats.anecdotes)
  • Re: how to make app "networkable" ?
    ... That really helps me with the big picture. ... > My application uses a single file to store its data currently. ... the broken "Reply" link at the bottom of the article. ...
    (comp.programming)