Sachin Hegde wrote:
>
> How do I efficiently delete all the entries in a Hash of arrays.
> suppose I have
> %HOA = { one => [ "a","b","c"],
> two => [ "x","y","z"],
> };
> I want
> %HOA = {};
Hi Sachin.
Your mistake lies in the difference between a hash and
a reference to a hash. The construct { .. } forms an
anonymous hash - a scalar value which is a reference
to a hash. This is a single value and can't be assigned
directly to a hash variable as a hash always requires its
content in (key, value) pairs.
I don't know exactly what you're trying to do, but for
your example code, either
%HOA = (
one => [ "a","b","c"],
two => [ "x","y","z"],
)
or
$HOA = {
one => [ "a","b","c"],
two => [ "x","y","z"],
}
will work fine. The first builds a hash with keys (one, two)
with array references for the corresponding values. The
second builds an anonymous hash with the same contents, and
assigns a reference to it to the scalar variable $HOA.
HTH,
Rob
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]