The first lesson of debugging should be: If you get an error performing an operation, make sure the arguments you are using are the ones you think you are using.

In other words, start by making sure you are using the file name you think you are using.

In this case, the error message even gives you a major hint that the file name you are using is not the one you meant to use. Does the file name you wish to use really have a linefeed in it? No.

The problem is that when you read in a line from a file, the linefeed is not removed for your. Use chomp($record); to remove the trailing linefeed. (In effect, this extracts the file name from the $record.)

Update: Actaully, your problem is worse than that. You want to read lines from file $file, right? If so, get rid of local $/ = \$maxsize;. If not, then you have more work to do, because $record contain a partial file name, a single file name or multiple file names, but you assume it contains a single file name.


In reply to Re: Unsuccessful and Uninitialized Value by ikegami
in thread Unsuccessful and Uninitialized Value 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.