For beginners non-cgi issues, there is also the '[EMAIL PROTECTED]'
list. Just for your info....

> While this is being used in a cgi, it's really more of a general perl 
> question.  But I'm hoping I can get some help.
> 
> I have a hash which has arrays of arrays as the value for each key:
> $tabset = 'clientInfo';
> %tabsets = (
>       clientInfo      => [('#', 'View Contact Information', 'Contact 
> Information'),
>                                       ('#', 'View the Job Log', 'Job Log'),
>                                       ('#', 'View the Client Assets', 'Client 
> Assets'),
>                                       ('#', 'View Press Releases', 'Press Releases')
>                                       ],
>       ); # data simplified and other keys removed...
> 

As your questions below state the above "lists" are getting flattened
into one array.  You need to reuse [] to build anonymous array
references like you did in the outer structure. So you end up with:

%hash = (  'key1' => [  [ '#1', 'View1', 'Title1',
                          '#2', 'View2', 'Title2' ],


> I want to be able to first get the array of arrays that matches a key, 
> keeping it as an array of arrays., then do a for each loop, keeping 
> access to the array of that array item (OK, bad description, I know...):
> 
> (here's where things go awry)
> 
> if (exists($tabsets{$tabset})) {
>       my @$tabs = @{$tabsets{$tabset}}; #this isn't right....
> 
>       foreach my @tab (@tabs) { #of course this isn't correct syntax, but 
> should illustrate what I intend to do
>               print "<a href=\"$tab[0]\" title=\"$tab[1]">$tab[2]</a>\n";
>       }
> } else {
>       &explode();
> }
> 
> 
> 
> What really happens will be a bit more complex, but that is the basic 
> logical structure is what I want.  But I rapidly get confused in what's 
> a reference, and how to refer to something without flattening my 
> 2-dimensional array into a flat array (so that the above array with 4 
> items which are each an array of 3 items ends up being a single array 
> of 12 items).
> 
> So, the questions are, how do I handle the references so I can maintain 
> the 2-dimensional-ness of my hash values, but still access them by key, 
> and then how do I use each item, which is an array, in a foreach loop?
> 
> TIA
> 
> 
> 
> 
> Chad A Gard
> http://www.percussionadvocates.com/chad
> 
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to