On Wed, 2002-04-03 at 16:42, James Taylor wrote:
> How do you get a list of all keys in a hash of arrays?  I'll have a hash 
> where the data would look something
> like:
> 
> %myhash = ('client19' => [ 'client2', 'client5', 'client7' ],
>                      'client20' => ['client3', 'client4', 'client8']);
> 
> 
> I need to basically get a list of the hash values and display the array 
> values for each one.
> 
> Thanks for your help!

The same way you would for a normal hash: keys.

%myhash = (
        client19 => [
                'client2',
                'client5',
                'client7',
        ],
        client20 => [
                'client3',
                'client4',
                'client8',
        ],
);

{
        local $"=', '; #set the LIST SEPARATOR var to ', '
        #print each key followed by the data it points to
        print "$_ => @{$myhash{$_}}\n" foreach keys %myhash;
}

-- 
Today is Pungenday the 20th day of Discord in the YOLD 3168


Missile Address: 33:48:3.521N  84:23:34.786W


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

Reply via email to