in reply to Re: Foreach in a 2D array
in thread Foreach in a 2D array
This is probably just a minor nit, but thought I might learn something. My understanding is that there is very little difference (from the perl interpreter standpoint) between:
andmy %hash = ('a', 'b', 'c', 'd');
my %hash = ('a' => 'b', 'c'=> 'd');
Advantages I can think of for the first representation are:
- As long as you know that a list has an even number of elements, you can use it as a hash.
The advantages I can think of for the second representation are:
- The => reads better from a maintainability standpoint
- you don't have to quote the key. For example:
my %hash = (a=>'b', c=>'d');
Essentially => is syntactic sugar for ,.
Update. Missed a tic.
"Look, Shiny Things!" is not a better business strategy than compatibility and reuse.
OSUnderdog
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Foreach in a 2D array
by hmerrill (Friar) on Oct 28, 2004 at 18:10 UTC |
In Section
Seekers of Perl Wisdom