A question for the cloister:

We have two arrays that have been sorted. I'm wondering if the straight comparison is good.

@sort_savedpids = sort {$a <=> $b} (@savedpids = get_saved_pids()); @sort_livepids = sort {$a <=> $b} (@livepids = get_live_pids()); if (@sort_savepids ne @sort_livepids ) { <DO STUFF> }
I'm a little concerned that there might be problems with possible 'extra' stuff in the array that might make the two arrays that are otherwise the same come up as not-equal.

Otherwise, would there be a method to cleanse the array to make sure it would just contain numbers? This would probably happen in the get_ routines.

-Kurt

In reply to Comparing sorted arrays by KPeter0314

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.