Maybe someone can help me with this so I can be on my way learning perl. I gone through a couple books on perl; however, it's not exactly sinking in. Maybe if someone can help me with a script or two I will start understanding Perl.
I want to parse the contents of this file.
VOLUME GROUP: datavg VG IDENTIFIER: 000d94600000d600000001117031c111
VG STATE: active PP SIZE: 128 megabyte(s)
VG PERMISSION: read/write TOTAL PPs: 4789 (612992 megabytes)
MAX LVs: 256 FREE PPs: 274 (35072 megabytes)
LVs: 20 USED PPs: 4515 (577920 megabytes)
OPEN LVs: 20 QUORUM: 6 (Enabled)
TOTAL PVs: 11 VG DESCRIPTORS: 11
STALE PVs: 0 STALE PPs: 0
ACTIVE PVs: 11 AUTO ON: yes
MAX PPs per VG: 32512
MAX PPs per PV: 1016 MAX PVs: 32
LTG size (Dynamic): 1024 kilobyte(s) AUTO SYNC: no
HOT SPARE: no BB POLICY: relocatable
This is the script that I have so far.
#!/usr/bin/perl -w
$TheFile = "lsvg_datavg";
open(INFILE, $TheFile) or die "The file $TheFile could not be found \n";
while (<INFILE>) {
$TheLine = $_;
chomp($TheLine);
my @values = split(/[(
;]/, $TheLine);
my @line = grep(/VOLUME GROUP:/, "@values");
my @line1 = grep(/TOTAL PPs:/,"@values");
my @line2 = grep(/FREE PPs:/,"@values");
print "\n";
print "@line";
print "@line1";
print "@line2";
}
This is the current output.
VOLUME GROUP: datavg VG IDENTIFIER: 000d94600000d600000001117031c111
VG PERMISSION: read/write TOTAL PPs: 4789 612992 megabytes
MAX LVs: 256 FREE PPs: 274 35072 megabytes
This is the output I'm looking for.
VOLUME GROUP: datavg
TOTAL : 612992 MB
FREE : 35072 MB
USED : 577920 MB
I want to parse the contents of this file.
VOLUME GROUP: datavg VG IDENTIFIER: 000d94600000d600000001117031c111
VG STATE: active PP SIZE: 128 megabyte(s)
VG PERMISSION: read/write TOTAL PPs: 4789 (612992 megabytes)
MAX LVs: 256 FREE PPs: 274 (35072 megabytes)
LVs: 20 USED PPs: 4515 (577920 megabytes)
OPEN LVs: 20 QUORUM: 6 (Enabled)
TOTAL PVs: 11 VG DESCRIPTORS: 11
STALE PVs: 0 STALE PPs: 0
ACTIVE PVs: 11 AUTO ON: yes
MAX PPs per VG: 32512
MAX PPs per PV: 1016 MAX PVs: 32
LTG size (Dynamic): 1024 kilobyte(s) AUTO SYNC: no
HOT SPARE: no BB POLICY: relocatable
This is the script that I have so far.
#!/usr/bin/perl -w
$TheFile = "lsvg_datavg";
open(INFILE, $TheFile) or die "The file $TheFile could not be found \n";
while (<INFILE>) {
$TheLine = $_;
chomp($TheLine);
my @values = split(/[(
my @line = grep(/VOLUME GROUP:/, "@values");
my @line1 = grep(/TOTAL PPs:/,"@values");
my @line2 = grep(/FREE PPs:/,"@values");
print "\n";
print "@line";
print "@line1";
print "@line2";
}
This is the current output.
VOLUME GROUP: datavg VG IDENTIFIER: 000d94600000d600000001117031c111
VG PERMISSION: read/write TOTAL PPs: 4789 612992 megabytes
MAX LVs: 256 FREE PPs: 274 35072 megabytes
This is the output I'm looking for.
VOLUME GROUP: datavg
TOTAL : 612992 MB
FREE : 35072 MB
USED : 577920 MB