On 08/08/2006 12:12 PM, n[ate]vw wrote:
I'm having some trouble using a hash of arrays. I thought I was starting to understand the jumbled mass of variable use in Perl, but perhaps not...

Instead of the missing switch() statement, I'm using a hash set up like this:

%zone_info = (
 'EST'  => [5,'EST', 4,'EDT'],
 'EST5' => [5,'EST-'],
 'CST'  => [6,'CST', 5,'CDT'],
 'MST'  => [7,'MST', 6,'MDT'],
 'MST6' => [6,'MST-'],
 'PST'  => [8,'PST', 7,'PDT'],
 'AKST' => [9,'AKST',8,'AKDT'],
 'AST'  => [4,'AST'],
 'HST'  => [10,'HST']
);

I can get values from deep inside it's bowels by a statement like:
 print $zone_info{'EST'}[3];

That gets repetitive, so I'd like to simplify it this way:
 @[EMAIL PROTECTED]'EST'};
 print $info[3];

...but that doesn't work! Nothing prints. What am I doing wrong?


You're not using the array reference in zone_info correctly.

my $info = $zone_info{'EST'};
print $info->[3];



thanks much,
-natevw


You're welcome.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to