in reply to wantarray and Tied Hashes
i seem to recall that hashes, even tied ones, are defined as associating an array of scalar values with an array of lookup keys; as such, i would expect that it's pretty likely that perl always calls FETCH in a scalar context.
as a quick test, you could try calling FETCH yourself in an array context, by saying (i think)
but, at the moment, i am not at a machine with perl. (shhh! don't tell anyone.) anyway, if that does want an array, then all is in order and perl is calling FETCH in a scalar context regardless; which, as i said, makes sense to me, since we might assume that hash values are scalars.my @array_i_said = FETCH(\%h, 'one');
i do wonder if there's a reason. is there any situation where FETCH would, if it kept the context the hash lookup was called in, return a list when we really want a scalar? i can't think of one...
.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: wantarray and Tied Hashes
by davorg (Chancellor) on May 24, 2001 at 15:09 UTC | |
by tye (Sage) on May 24, 2001 at 23:31 UTC | |
by Vynce (Friar) on May 26, 2001 at 03:04 UTC |