using Perl grep to populate a scalar
0 answers - 1782 bytes -

Message
From: Smith, Derek
Sent: Tuesday, May 09, 2006 5:22 PM
To: Perl Beginners
Subject: using Perl grep to populate a scalar
All,
I am trying to populate a scalar (ideally a hash) using a Perl grep but
it is not working. I even tried to use an array and no data was pushed.
use strict;
use warnings;
my @lvs;
my @lvaray = qx(bdf);
foreach (@lvaray) {
if (/(?)vg00/) {
push @lvs, (split)[0]
}
}
my %hash = ();
my (@key2,$value2) = 0;
foreach (@lvs) {
$key2[$value2++] = (grep /mirror/gi, `lvdisplay $_` );
}
print $key2[1];
What my hash should print for testing is data as such:
Logical volumes
LV Name /dev/vg00/lvol1
VG Name /dev/vg00
LV Permission read/write
LV Status available/syncd
Mirror copies 1
Consistency Recovery MWC
Schedule parallel
LV Size (Mbytes) 512
Current LE 64
Allocated PE 128
Stripes 0
Stripe Size (Kbytes) 0
Bad block off
Allocation strict/contiguous
I Timeout (Seconds) default
But I only want the lines: lv name /dev/vg00/lvol1 and mirror copies 1
For a key value relantionship.
Thank you
Derek
Any thoughts?
Cardinal Health -- Working together. For life. (sm)
This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the email by you is prohibited.
Dansk - Deutsch - Espanol - Francais - Italiano - Japanese - Nederlands - Norsk - Portuguese - Svenska: