When you use a filehandle in a list context (e.g. your line @second_file{map { unpack 'A*', $_ } <$b_fh>} = ();) it reads the entire contents splitting it into lines (modulo $/ of course; see perlvar). The next time you use that same filehandle, since everything's been read from the file it's just going to return undef because it's at the end of the file. You need to either close and re-open it, or use seek to set the file pointer back at the beginning of the file (at which point reading from it will again return the lines).

@second_file{map { unpack 'A*', $_ } <$b_fh>} = (); seek( $b_fh, 0, 0 ); ## Reset $b_fh back to the beginning

That aside, if you're on a *NIX-y system you might be interested in the diff or cmp commands instead.

The cake is a lie.
The cake is a lie.
The cake is a lie.


In reply to Re: output using map by Fletch
in thread output using map by coding_new

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.