Uhm... some things to point out here

First, you don't use strict, and it hurts :-); it would have catched, for example:

%file2 = 'Source.txt' ;

which is an error, twice. First, because you are using an hash instead of a variable; second, because you are assigning an odd number of elements to an hash

Second, you are slurping two files into memory, and that could be a pain if the files are too big, compared to your memory; probabily, you could do with reading one of the two line per line, and cache the other.

Third, you have three cycles, put probabily you could just grep; more on this later, because there is a badder thing before:

You open and close conversion.txt over and over: that is expensive! Why don't just open(APPEND, ">>conversion.txt") ; on top, close(APPEND); on bottom and print(APPEND "$line2") ; (watch the unbalanced parenthesis on that line!) when required?

You are comparing $line1 and $line2 with !=: that's a numerical comparison. If you want to do the same test on strings, you should use ne instead.

And now about the cycles: one way to compact them could be:

foreach my $line1 (@lines1) { print APPEND grep $line1 ne $_,@lines2 ; }

Take a look at the documentation (perldoc -f grep) to know more about grep

Apart of the errors, keep studying perl. Maybe your program is not that good still, but it seems to me you are headed in the right direction ;-)

Ciao!
--bronto


In reply to Re: Comparing 1 list and 1 array by bronto
in thread Comparing 1 list and 1 array by Anonymous Monk

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.