I quickly re-wrote the logic in the sub to iterate over the user-args in the outer loop, then do the loop over the structure on the inner loop. This makes it a bit easier to achieve what I believe you want.

First, I removed the re-assignment of the parameters to avoid unnecessary overhead, and just use the aref directly in the code. Other than the restructuring, I've also changed from iterating over the inner array within the hash to just using grep instead. Note I've also added a $found flag. This is how we track whether the WWN has been found or not within the entire structure. This variable gets reset each time we look for a new user-supplied WWN.

The code assumes that only a single WWN can be found in the entire structure. If it can be in numerous places (which I can't see how and would indicate larger issues I would think), then change the last to a next inside the grep condition.

sub _compare_match_WWPN { die "no parameter!\n" unless @_; my ($w_ref) = @_; for my $name (@{ $w_ref }){ my $found; for my $rmtkey (sort keys %wwns){ if (grep {$name eq $_} @{ $wwns{$rmtkey} }){ print "Found '${name}' that belongs to $rmtkey\n"; $found = 1; last; } } if (! $found){ print "$name not found!\n"; } } return; }

Output:

Enter your wwns to search for? More than one, comma seperated: ---> 20 +09000g123456ff,500143802483cfe5 2009000g123456ff not found! Found '500143802483cfe5' that belongs to rmt42

In reply to Re: search HoA-reference by stevieb
in thread search HoA-reference 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.