in reply to Strange read file behaviour

I don't know what exactly is happening, so please can you explain?

Your file directories.txt was created on a Windows machine so it has <CR><LF> ("\r\n") line endings and chomp on Unix will only remove the <LF> and leave the <CR>.

Replies are listed 'Best First'.
Re^2: Strange read file behaviour
by almut (Canon) on Jun 28, 2010 at 12:20 UTC
    and chomp on Unix will only remove the <LF>

    This is correct, but the "on Unix" kind of implies that this would be different on Windows — which it isn't.  On Windows it also only removes a linefeed.  But that's ok, as on Windows the crlf layer has already translated the \r\n to \n while reading in the line.