You're welcome, you did a good job of turning my pseudo-code into working code!

One suggestion: don't create variables outside a loop if they're only used within the loop. So your @array1 can be instantiated inside your first loop, like this:

my @array1 = split (" ", $_);

Same thing with @array2, $str, and $string. The way you're doing it will work, but it may introduce bugs in more complicated code, because those variables will continue to exist after those loops are finished, and could conflict with other uses elsewhere. It's best to keep variables inside as small a context as possible, so only create them outside a loop if you need them to continue to exist after the loop is finished.

Aaron B.
Available for small or large Perl jobs and *nix system administration; see my home node.


In reply to Re^7: Compare three columns of one file with three columns of another file in perl by aaron_baugher
in thread Compare three columns of one file with three columns of another file in perl by anonym

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.