Kris0r:

Apparently, I've not had enough coffee this morning--I missed your last sentence. It's complaining that $_ is not numeric. So I'm guessing you're iterating over the list of strings rather than a list of numbers when processing the array, something like:

my @array1 = ('foo', 'bar', 'baz'); my @array2 = ('zim', 'zam', 'baz'); # should work: for (0 .. $#array1) { if ($array1[$_] eq $array2[$_]) { print "match! $array[$_]\n" } else { print "mismatch $array1[$_] ne $array2[$_] } } # should give a similar error: for (@array1) { if ($array1[$_] eq $array2[$_]) { print "match! $array[$_]\n" } else { print "mismatch $array1[$_] ne $array2[$_] } }

Try printing the value of $_ before using it as an array index, and you'll see what perl is complaining about.

You're not showing your comparison code, but from the error message, I'm guessing you're using the numeric equality operator (==) rather than the string equality operator (eq) to compare lines.

Update: Rewrote node after re-reading OP and realizing my goof.

...roboticus

When your only tool is a hammer, all problems look like your thumb.


In reply to Re: File to array and reading back by roboticus
in thread File to array and reading back by Kris0r

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.