[Omaha.pm] Reading a Unix vs a DOS text file
Jay Hannah
jay at jays.net
Thu Mar 26 09:38:14 PDT 2009
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
More information about the Omaha-pm
mailing list