I have some code like:
my %hosts = (
'USAmazon' => ['US','CA'],
'EUAmazon' => ['GB', 'FR', 'IT', 'ES', 'DE'],
'CNAmazon' => ['CN'],
'JPAmazon' => ['JP'],
);
my @values = $hosts{$ARGV[0]};
I see that $values[0][0] holds US and $values[0][1] holds CA. Why is that so? Please explain.
Also, how do I find out the length of $values[0]?
scalar $values[0] prints out something like ARRAY(0x12FFc) blah..blah…
Any links are also helpful.
Array and hash values are always scalars. In this case, for existing elements,
$hosts{$ARGV[0]}is a scalar containing a reference to an array. You need to dereference that reference to get the array.