Re: tied hash



Konrad Eisele wrote:
> 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');
>
>
> package Ta;
> use Tie::Hash;
> @ISA = qw(Tie::StdHash);
>
> sub STORE {
> return [1,2,3];
> }
>
>
>
>
> I'd like to get @a == [1,2,3]


Couldn't you avoid the STORE operation entirely
and assign to @a first? If you want it on
one line, then try something like:

tie %foo, 'Ta';
$foo{bar} = [ my @a = ([1, 2, 3]) ]->[0];


--
Hope this helps,
Steven

.



Relevant Pages

  • tied hash
    ... I have a tied hash, ... On a tied 'STORE' I want to get the return values of the STORE function. ... a naive aproach would be ...
    (comp.lang.perl.misc)
  • Re: tied hash
    ... Konrad Eisele wrote: ... > I have a tied hash, ... On a tied 'STORE' I want to get the return ... assignment returning the assigned value is implemented with FETCH ...
    (comp.lang.perl.misc)
  • Re: tied hash
    ... > values of the STORE function. ... How do i have to reorder the expression?? ... in a tied hash, ... "Reply" at the bottom of the article headers. ...
    (comp.lang.perl.misc)