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

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





On Thu, Mar 26, 2009 at 11:38 AM, Jay Hannah <jay@jays.net> wrote:
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?   :)

That does help.

I mentioned binmode because I saw several references to that, but your solution is better.

I knew someone would know more than me.  I just moonlight in Perl. :)


--
Mike Hostetler
http://mike.hostetlerhome.com/