[Omaha.pm] Reading a Unix vs a DOS text file
Mike Hostetler
hostetlerm at gmail.com
Thu Mar 26 11:14:19 PDT 2009
On Thu, Mar 26, 2009 at 11:38 AM, Jay Hannah <jay at 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/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/omaha-pm/attachments/20090326/36976df1/attachment.html>
More information about the Omaha-pm
mailing list