in reply to Trouble accessing Hash of Arrays
Hello sujeet97, and welcome to the Monastery!
As Anonymous Monk says, you need to store references to the two arrays. This:
#! perl use strict; use warnings; my %sampleHash = (); my @array1 = ('a', 'b', 'c'); my @array2 = ('x', 'y', 'z', 's'); $sampleHash{hash1} = \@array1; $sampleHash{hash2} = \@array2; print $sampleHash{hash1}[0];
prints a as desired. See perlreftut and perlref.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Trouble accessing Hash of Arrays
by sujeet97 (Initiate) on Apr 02, 2013 at 02:49 UTC |