I don't know if I understand your question, but you could grab the vgname and stick it in a variable like $now_vgname, and do the same with the label and then build your hash when you get the id. EG
...
my ($now_vgname,$now_label);
while ( <$input_handle> ) {
if ( /lsattr -El (\w+)/ )
$now_vgname = $1;
next;
}
if ( /label\s+([\/\w]+)/ ) {
$now_label = $1;
next;
}
if ( /lvserial_id\s+([\w\.]+)/ ) {
$host_info{VG}->{$now_vgname}->{$1}->{LV} = $now_label
next;
}
}
This code is just to demonstrate the idea, it probably won't work as is.
--Pileofrogs