in reply to From arrayref to hashref
An addendum to broquaint for ref newbies:
One thing that got me about array/hash refs is that I can assign an array to a hash, even elements becoming keys, odd elements becoming values:
@array = (Bannana, Fruit, Corn, Vegetable); %hash = @array;# (Bannana => Fruit, Corn => Vegetable);
But you cannot dereference an array ref to a hash:
$food = \@array; print $$food{Corn}; # woops!
Once I realized how it worked, I thought that I was stupid to have suspected otherwise - until I learned it was a semi - common problem.
Hope that helps!
Cheers,
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: From arrayref to hashref
by Sidhekin (Priest) on Mar 21, 2002 at 17:06 UTC | |
by erikharrison (Deacon) on Mar 21, 2002 at 19:08 UTC |