Hi y'all! I have made a lot of progress on my own, but I think I'm stuck. As you can see in the output, vhost0 is the key and the values are the l02s strings likewise for vhost5. When the code gets into the if condition, it only wants to print 1 one of these lines. Why? Please correct any inefficient code too. My goal is to not print any vhost that has values of 'NO VIRTUAL TARGET DEVICE FOUND', hence my grep. Thank you!
use strict; use warnings; my (@vhost,%vhosts,$vh,$vdata,$vadapter,$lsm); open (LSMAP, "-|", "/usr/ios/cli/ioscli lsmap -all") or die $!; while ($lsm = (<LSMAP>)) { $lsm =~ s/backing device//i; $lsm =~ s/vtd//i; $lsm =~ s/U9117.*//i; $lsm =~ s/0x0.*//; next if $lsm =~ /^\s*$/; next if $lsm =~ /^--/; next if $lsm =~ /^SVSA|^Physloc.?|^Mirrored.*|status.*|lun.*|vtscs +i\d+/i; ($vh) = map { (split)[0], } $lsm if $lsm =~ /vhost.*/; push( @{$vhosts{$vh}}, $lsm); } use Data::Dumper; #print Dumper \%vhosts; for my $key (keys %vhosts) { $vadapter = $key; #print @{$vhosts{$vadapter}}; #if ( grep /no virtual target device found/i, @{$vhosts{$vadapter} +} ) { # pop @{$vhosts{$vadapter}}; # print @{$vhosts{$vadapter}}; #} if ( !grep /no virtual target device found/i, @{$vhosts{$vadapter} +} ) { # print @{$vhosts{$vadapter}}; print split(/\n|\.\w+/,"lu -map -clustername asccl-eta1 -sp st +p-eta1 -vadapter @{$vhosts{$vadapter}}[0] -lu @{$vhosts{$vadapter}}[1 +]" ),"\n"; } } __OUT__ Notice vhost3 is not in this out. vhost0 l02duapofdev_r1.58ff94782d7c325acc49a8dd9c04bb1e l02duapofdev_b1.0ee86903d4951ce38a9b691b322ff1d2 vhost5 l02duapofqa_r1.4746343ea4f12fe1092615c8734d9844 l02duapofqa1_d1.449583501d812f69e6189ea7f4a29e06 # perl viomap_N_bulk.plx # Only printing one of the 2 lines, I should see l02duapofdev_r1 and + l02duapofdev_b1 lu -map -clustername asccl-eta1 -sp stp-eta1 -vadapter vhost0 + -lu l02duapofdev_r1 lu -map -clustername asccl-eta1 -sp stp-eta1 -vadapter vhost5 + -lu l02duapofqa_r1 __OUT_w_printing_AoH__ # perl viomap_N_bulk.plx vhost7 l02dudbofqa_r1.b524c0f6b39978167278afa7adfc186b l02dudbofqa1_a1.682aa3eab2f95f41f4e61267f1eed32d l02dudbofqa1_a2.0063f2629d0245d7c1733b612dd60ab6 l02dudbofqa1_a3.32d800ee33ed30ef8a3608c6159782ac l02dudbqa1_d1.fe1b01b781bc4b5060ee46cf76280d2d l02dudbofqa1_d2.2f70fff82f86b6a671feac7a4fd87b35 l02dudbofqa1_d3.b409863d75262fc9b79acf517c676e0b l02dudbofqa1_d4.2f6e94f56e6153ade4f92a98c802da5c l02dudbofqa1_d5.a2f5295a1c384b48fd9e5ae5f2a948b2 l02dudbofqa1_d6.42a707c7c349d835a35230606836e1da vhost6 l02dzuapofqa_r1.095f2dc597a4bf3b2813353e51ac5100 l02dzuapofqa_d1.afb45ce1f5d7680be6121fc52621e9da vhost3 NO VIRTUAL TARGET DEVICE FOUND __LSMAP-ALL_OUT__ # /usr/ios/cli/ioscli lsmap -all SVSA Physloc Client Pa +rtition ID --------------- -------------------------------------------- --------- +--------- vhost0 U9117.MMD.218A8B7-V1-C2 0x0000000 +b VTD vtscsi0 Status Available LUN 0x8100000000000000 Backing device l02duapofdev_r1.58ff94782d7c325acc49a8dd9c04bb1e Physloc Mirrored N/A VTD vtscsi1 Status Available LUN 0x8200000000000000 Backing device l02duapofdev_b1.0ee86903d4951ce38a9b691b322ff1d2 Physloc Mirrored N/A SVSA Physloc Client Pa +rtition ID --------------- -------------------------------------------- --------- +--------- -------------------------------------------- ------------------ vhost3 U9117.MMD.218A8B7-V1-C14 0x0000000 +0 VTD NO VIRTUAL TARGET DEVICE FOUND SVSA Physloc Client Pa +rtition ID --------------- -------------------------------------------- --------- +--------- vhost5 U9117.MMD.218A8B7-V1-C16 0x0000000 +7 VTD vtscsi22 Status Available LUN 0x8100000000000000 Backing device l02duapofqa_r1.4746343ea4f12fe1092615c8734d9844 Physloc Mirrored N/A VTD vtscsi23 Status Available LUN 0x8200000000000000 Backing device l02duapofqa1_d1.449583501d812f69e6189ea7f4a29e06 Physloc Mirrored N/A

In reply to array of hash ref? by teamassociated

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.