For a single level of indirection, as shown in your example, no. (And if you do, don't use the variables $a and $b, leave them for sort comparison functions).
On the other hand, for deeply nested hashes, yes, absolutely, assuming you're going to refer to the variable two or more times. It will make your code much more compact and easier to read.
my $bytes = $self->{center}{floor}{room}{bay}{rack}{unit}{port}{tran +smitted}; if( $bytes == 0 ) { print "Nothing transmitted.\n"; } elsif( $max < $bytes ) { $max = $bytes; } else { $sum += $bytes; } }
Keep in mind that I'm not doing this for performance reasons, I'm only concerned about readability.
In reply to Re: Should we bother to save hash lookups for performance? (yes, sometimes)
by grinder
in thread Should we bother to save hash lookups for performance?
by dlink
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |