S
Steve
Forgive a newbie question, but I'm hoping that someone can shed some
light for me on weirdness I'm seeing when trying to access a particular
hash from an array-of-hashes. I had a lot of difficulty assigning a
particular element to its own variable, but after some experimentation I
found that this works:
my @array = MyModule->getArrayOfHashes();
my $hash = $array[$index];
%hash = %$hash;
I have to first create the variable in scalar context, then do a funky
dereferencing thing while changing the context to hash. For one thing,
I'd like to better understand what is really going on here... I just
stumbled across this solution through experimentation and dumb luck, I
don't really understand it. Secondly, I'm wondering if there's some
shorthand technique for doing this that doesn't require three lines of
code. Thanks in advance!
light for me on weirdness I'm seeing when trying to access a particular
hash from an array-of-hashes. I had a lot of difficulty assigning a
particular element to its own variable, but after some experimentation I
found that this works:
my @array = MyModule->getArrayOfHashes();
my $hash = $array[$index];
%hash = %$hash;
I have to first create the variable in scalar context, then do a funky
dereferencing thing while changing the context to hash. For one thing,
I'd like to better understand what is really going on here... I just
stumbled across this solution through experimentation and dumb luck, I
don't really understand it. Secondly, I'm wondering if there's some
shorthand technique for doing this that doesn't require three lines of
code. Thanks in advance!