Re: tied hash
- From: "attn.steven.kuo@xxxxxxxxx" <attn.steven.kuo@xxxxxxxxx>
- Date: 27 Jul 2005 13:12:24 -0700
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
.
- References:
- tied hash
- From: Konrad Eisele
- tied hash
- Prev by Date: Re: Active State Perl
- Next by Date: Read first few lines from command output
- Previous by thread: Re: tied hash
- Next by thread: Re: tied hash
- Index(es):
Relevant Pages
|
|