Hi All New to this group, so hello to everybody.
I am currently working on creating a Array of Hashes, note it is a work in progress. I appear to be getting some corruption when inputting data with the pvdisplay, I can't see why this is the case. I have put some print statements to see where I am going wrong and I suspect the logic of the script is incorrect. Below is the script: Scroll down further to see the output and hopefully it will make sense what I am asking. #!/usr/bin/perl use strict; use warnings; my @vggroup; my @PV; my $PV=0; my $Extents; my $AllocatedPE; my $rec = {}; my $href; my $extent; open(CMD,"/usr/sbin/vgdisplay -v vg03|"); while(<CMD>) { if (/PV Name/) { $PV = (split(/\s+/, $_))[3]; push @PV, $PV; } } print "@PV \n"; foreach $PV (@PV) { open(EXT,"/usr/sbin/pvdisplay $PV|"); while(<EXT>) { <-- This is aware I appear to be going wrong, scroll down further. print $_; <--- if (/Free PE/) { $AllocatedPE = (split(/\s+/, <EXT>))[2]; $rec->{$PV} = $AllocatedPE; print "$PV "; print $rec->{$PV}; print " \n"; push @vggroup, $rec; } } } for $href (@vggroup) { print "{ "; for $extent ( keys %$href ) { print "$extent=$href->{$extent} "; } print "}\n"; } close(EXT); close(CMD) Result: /dev/disk/disk46 /dev/disk/disk48 /dev/disk/disk47 /dev/disk/disk46 159 /dev/disk/disk48 159 /dev/disk/disk47 0 { /dev/disk/disk46=159 /dev/disk/disk48=159 /dev/disk/disk47=0 } { /dev/disk/disk46=159 /dev/disk/disk48=159 /dev/disk/disk47=0 } { /dev/disk/disk46=159 /dev/disk/disk48=159 /dev/disk/disk47=0 } /dev/disk/disk46 /dev/disk/disk48 /dev/disk/disk47 --- Physical volumes --- PV Name /dev/disk/disk46 VG Name /dev/vg03 PV Status available Allocatable yes VGDA 2 Cur LV 1 PE Size (Mbytes) 64 Total PE 159 Free PE 0 /dev/disk/disk46 159 <-- The lines in bold are getting inserted, when reading with the pvdisplay. I should be seeing --> Allocated PE 0 Stale PE 0 Why is this occurring? IO Timeout (Seconds) default Autoswitch On Proactive Polling On --- Physical volumes --- PV Name /dev/disk/disk48 VG Name /dev/vg03 PV Status available Allocatable yes VGDA 2 Cur LV 1 PE Size (Mbytes) 64 Total PE 159 Free PE 0 /dev/disk/disk48 159 Stale PE 0 IO Timeout (Seconds) default Autoswitch On Proactive Polling On --- Physical volumes --- PV Name /dev/disk/disk47 VG Name /dev/vg03 PV Status available Allocatable yes VGDA 2 Cur LV 0 PE Size (Mbytes) 64 Total PE 159 Free PE 159 /dev/disk/disk47 0 Stale PE 0 IO Timeout (Seconds) default Autoswitch On Proactive Polling On Cheers