Hi Frank
On 07/10/2014 11:02 AM, SSC_perl wrote:
On Jul 10, 2014, at 7:14 AM, Nathan Hilterbrand wrote:
$entries{$state} = [ (split /,/ => $zipcodes) ];
Thanks, Nathan. The line above caught my eye. It's interesting to see
that you don't need both 'push' and 'split' to populate the hash.
Could you explain a little about what the square brackets are for here?
Does that have something to do with array ref's? Sorry... hashes are a weak
spot of mine.
Yes, it does use an array ref. What it says, briefly, is "split
$zipcodes into individual values, splitting by ',' , and place those
values into a list. Use that list to create an array reference, and
assign it to the element of $entries keyed by $state."
I also noticed that you wrote the split as
(split /,/ => $zipcodes)
instead of
split (/,/ => $zipcodes)
Is that just a stylistic difference or is there something more to it? Both
work for me.
It is strictly stylistic, and I did it to match your split that is
below. It doesn't really behave any differently than a comma in any way
that is relevant for this usage.
Frank
http://www.surfshopcart.com/
Setting up shop has never been easier!
Now on GitHub
https://github.com/surfshopcart/surfshop
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/