OK, so let's unpack what you did:
for my $lun ( ('SAN_VC0_42','SAN_VC0_43') ) { $luns_to_hdisk {$lun} = { grep /hdisk\d+/, qx(vxdisk list $lun) } +; } ;
the qx(vxdisk list $lun) is invoked in List Context, so will return a list, each entry of which is one line as returned by the vxdisk command -- complete with line-ending.
the grep returns a list which is a subset of the list returned by qx, selecting the entries which match /hdisk\d+/
that is enclosed by {}, which in this case comprise an anonymous hash constructor -- constructing a hash with the even numbered entries that matched /hdisk\d+/ as keys, and the odd numbered entries as values.
a reference to that anonymous hash is assigned to $luns_to_hdisk{$lun}
that is done for $lun set to 'SAN_VC0_42' and then 'SAN_VC0_43'
I guess that's not what you intended ?
What did you have in mind ?
If you want $luns_to_hdisk{$lun} to be a list of the /hdisk\d+/ lines, you are very nearly there... you just need the anonymous list constructor [], not the anonymous hash constructor {}. That would be an HoL, though -- which is not what you were apparently wanting ?
You may want to consider a chomp somewhere or other to remove the line-endings from the selected lines. It's not clear whether you want the 'state=enabled' part, and if not you need a little extra code there.
In reply to Re: trying HoH
by gone2015
in thread trying HoH
by mikejones
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |