[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Omaha.pm] Reading a Unix vs a DOS text file



Mike Hostetler wrote:
So . . . it there a way I could get Perl to detect a file that uses CRLF as
it's line terminator?  That way, I could use binmode on that file, and use
ASCII on the rest.  Or does someone have a better suggestion?

binmode is for binary files.

CRLF (\r\n Windows) and LF (\n *nix) are for text files.

I think you are confusing those two issues. They are not related. When reading a file you could

while (<IN>) {
  s/[\r\n]+$//;

to remove those characters regardless of which format any given file was written in.

Does that help?   :)

j