in reply to Unsuccessful and Uninitialized Value

I think that the error message is pretty clear here.

Unsuccessful stat on filename containing newline

You're reading the filename from a file. Each record that you read from the file has a newline on the end. You need to remove that before using it.

I'd be interested in hearing ideas on how that error message could be made clearer.

--
<http://dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg

  • Comment on Re: Unsuccessful and Uninitialized Value

Replies are listed 'Best First'.
Re^2: Unsuccessful and Uninitialized Value
by runrig (Abbot) on Jun 05, 2006 at 16:20 UTC
    I'd be interested in hearing ideas on how that error message could be made clearer.

    "...(maybe you forgot to chomp?)"

    ;-)

    Update: Looking closer at the OP's code, chomp is not the problem of course. The problem is the use of $/ which ikegami has noticed further down. But I still like my (joking) error message addition, as it sounds similar to the non-existant package/method error :)

      I did use chomp, and it still didn't work.
        Do you know what setting $/ does? If set to a reference to an integer, it reads in that many bytes (and in your case one or more of those bytes contains a newline). It does not merely set the "maximum" number of bytes read. Is that what you wanted (this would be appropriate for a fixed length format)? Or are you trying to read in the file one "line" at a time? What does one line of the file look like? Does one line contain one file name? Or more?