in reply to Re: Windows file read
in thread Windows file read

I am currently opening the file using:

open IN, '<:utf8', $file or die "Can not open input file: $file";

It was my understanding that specifying a format while opening the file will open it, then call binmode on it. Is this incorrect?

Replies are listed 'Best First'.
Re^3: Windows file read
by ikegami (Patriarch) on May 01, 2006 at 16:27 UTC

    I'm not very familiar with PerlIO (:utf8, etc). I suspect that if you do

    open IN, '<:utf8', $fn or ...; binmode(IN); # Short for binmode(IN, ':raw') in v5.8

    you will lose the :utf8 property. You could try

    open IN, '<:raw:utf8', $fn or ...;

    but :raw and :utf8 might be mutually exclusive. Fortunately, it's easy to try these and see if they work.

    Update: This page says the previous snippet will work. Your code would look like:

    local $/ = "\x0D\x0A"; open(local *IN, '<:raw:utf8', $filename) or die("Unable to open input file $filename: $!\n"); while (<IN>) { chomp; s/\x0A/ /g; ... }