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?

$zone_info{ EST } contains a reference to an array.  To copy the array it
references you have to dereference it.

my @info = @{ $zone_info{ EST } };



John
-- 
use Perl;
program
fulfillment

-- 
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