Hamish Whittal wrote:

> Thanks Rob, this has been very helpful. I wanted to know why the second
> form is an abuse of perl. Since I'm new to perl, it is helpful to kn ow
> what is good programming practise.

Because it adds characters and notation that serve no purpose, which serves
no purpose.  There are more clear ways to write anything intended here:
If you have a hashame and want an element:
$config{$key}
If you have a reference and you want the element
$config_ref->{$key}
$$config_ref{$key}
${$config_ref}{$key}
All indicate what is happening more clearly.
What actually happens in the case Rob cites is much more indirect, and
invokes unnecessary processig.

The only real reason to dereference a hash as a whole is to pass to
functions calling for a hash, such as the keys function:
foreach (keys %{$config_ref})
or
oreach (keys %$config_ref)

Otherwise you get there much faster and more cleanly by just playing off the
reference, using the arrow operator.  It may seem a bit cumbersome at first,
but after you get used to it, it speaks very clearly of the process invloved
with pointing from the reference given to the desired element or member
function.

Joseph


Joseph


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to