There's more than one way to do things | |
PerlMonks |
Re: Re: Printing a hash in a specific order?by Limbic~Region (Chancellor) |
on Mar 15, 2003 at 16:01 UTC ( [id://243307]=note: print w/replies, xml ) | Need Help?? |
Anonymous Monk,
It is magic - bad magic, but magic none the less. Without showing you my very poorly written OO code. Basically, I am creating a complex hash (HoHo...). There is really only one key to the hash at any one time - which points further down the complex structure. So $hashref is a scalar that is a reference that points to the actual hash. The %{$hashref} is dereferencing the reference it to make it look like a real hash. The keys extracts the one and only key that is there. Putting the parens around the my ($key) part changes the context from scalar (which would have returned the number of keys i.e. 1) to a list context (which returns the one and only key). Cheers - L~R
In Section
Seekers of Perl Wisdom
|
|