----- Original Message -----
From: Gary Stainburn <[EMAIL PROTECTED]>
To: Perl Beginners <[EMAIL PROTECTED]>
Sent: Thursday, May 31, 2001 1:21 PM
Subject: array inside a hash


> Hi all,
>
> I'm writing a small script to collect info from various system commands
> to produce a small meaningfull report on our AIX box.
>
> I have a hash %pvolumes which lists all my physical volumes, and I can
> add scalars to it no problem, e.g.
>
> $pvolumes{$pvolume}->{vgroup}=$vgroup;
>
> however, I want to have  an array containing the logical volumes held
> on the phsical one, but I can't get the syntax right.  I tried
>
> push @$pvolumes{$pv}->{volumes},"$lv:$lp:$pp:$dist";
> push $pvolumes{$pv}->{volumes},"$lv:$lp:$pp:$dist";
>

First read perllol (list of lists).
I assume you want to use the physical volumes as a key in your hash.
Them why do you first put a hashref in the hash, and a list in that hashref.
This should work:

push @{$pvolumes{$pv} }, "$lv:$lp:$pp:$dist";

i assume  the scalar "$lv:$lp:$pp:$dist" represents 1 logical volume and
this stament is in a loop.

Maarten


Reply via email to