Hi Monks, I have 5 arrays containing inter-related data that I need to match up. I would like to have a normal hash, but how do I know if I need a hoh or hoa? Regardless, array1 contains diskgroup names, array2 contains filesystem names, array3 contains hdisks, array4 contains sizes of these hdisks and array5 contains lun ids. I would like to have array1 data be the key and the rest of the array's date be values. Or is there a better way? Thank you.
# of elements per array 14 array1 53 array2 416 array3 416 array4 52 array5 I have tried these ways unsuccessfully my %hash = (); @hash{ @array1,@array2,etc } = @list; AND for (@nodupLuns) { $hash{@dgarray}{@fs}{@nodupHdisks}{@sizes} = { 'lunid' => $_ }; } __CODE__ #!/usr/bin/perl use strict; use warnings; $ENV{PATH} = qq(/usr/sbin:/usr/bin); my @dgarray; open (DG, "vxdg list |") or die "vxdg did not open $!"; while (<DG>) { next if /name/i; push @dgarray, +(split)[0]; } close (DG); my (@hdisks,@sizes,@nodupHdisks,@nodupLuns,@lunid,$svc,$dg,$hdisk,@fs, +$lun); for $dg (@dgarray) { open (DF, "df -k |") or die "df did not open $!"; while (<DF>) { if ( /$dg/ ) { push @fs, +(split)[6]; } } close (DF); open (VXP, "vxprint -thvm -g $dg |") or die "vxprint did not open +$!"; while (<VXP>) { if ( /device_tag/ ) { my @tmp = (split /device_tag=/); for $svc (@tmp) { open (VXD, "vxdisk list $svc |") or die "vxdisk list f +ailed $!"; while (<VXD>) { if ( /state=\w+/ ) { push @hdisks, (split /state=enabled/); } } } } } close (VXD); } my %counts; @nodupHdisks = grep { $_ =~ /hdisk\d+/ and ++$counts{$_} < 2 } @hdisks; @sizes = map `bootinfo -s $_`, @nodupHdisks; for $lun (@nodupHdisks) { open (LUNID, "lscfg -vl $lun |") or die "lscfg failed $!"; while (<LUNID>) { if (/serial/i) { push @lunid, substr($_,-33); } } } %counts = (); @nodupLuns = grep { $_ =~ /\w+/ and ++$counts{$_} < 2 } @lunid;

In reply to arrays, hoh? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.