Sorry I wasn't so clear. Let me go into a little more detail on what I’m trying to accomplish. The @list is coming from a file handler that returns a list from a sys. command. The length varies is so I’m just cycling through it in while statement. In a nut shell all I’m doing is looking to see if all the elements are present in the new "@list" and let the user know which elements are missing.
open($syscmd,"ps -a |") || die "unable to open system command $!\n"; $count =0; while (<$syscmd>){ @list1 = split(" ", $_); @list[$count] = @list1[3]; $count = $count + 1; } $set = 0; foreach $val(sort keys(%prolist)){ #checks through every element +in the hash one by one. while(<@list>){ #looks through each element in list for a matc +h if ($prolist{$val} eq $_ ){ #if the match is found $set = 1; #sets this to true so that the below if sta +tment isn't executed last; } } if ($set == 0){ #prints only if there is no match print + "NF: $prolist{$val}\n"; } $set = 0; #resets boolen }

In reply to Re: Re: loop control by maxl90
in thread loop control by maxl90

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.