Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Re: Re: Re: Handling Mac, Unix, Win/DOS newlines at readtime...

by graff (Chancellor)
on Sep 16, 2002 at 04:30 UTC ( [id://198149]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Re: Handling Mac, Unix, Win/DOS newlines at readtime...
in thread Handling Mac, Unix, Win/DOS newlines at readtime...

but what if a file was created on a Windows machine, but this code was being run on a Mac?

It wouldn't matter which type of system was running the perl code.

I remember reading somewhere in this thread that \r and \n have reversed semantics on the Mac (vs. *nix, Windows).

Um, no, that statement hasn't been made on this thread. My own experience has been that MS systems use "\r\n", all .n.x systems use "\n" and (older) Mac systems use "\r". Nobody uses "\n\r".

And now that MacOS-X is out with a unix foundation, maybe the number of variants will reduce to just two instead of three.

  • Comment on Re: Re: Re: Re: Handling Mac, Unix, Win/DOS newlines at readtime...

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Handling Mac, Unix, Win/DOS newlines at readtime...
by IlyaM (Parson) on Sep 16, 2002 at 07:58 UTC
    Nobody uses "\n\r".

    This reminds me days when I just started using Perl. One of my first real scripts was supposed to handle both Unix and Win32 line endings in input text files. However one day it borked because of input file having "\n\r". No idea where such line ending came from though.

    --
    Ilya Martynov (http://martynov.org/)

Re: Re: Re: Re: Re: Handling Mac, Unix, Win/DOS newlines at readtime...
by bart (Canon) on Sep 17, 2002 at 04:05 UTC
    I remember reading somewhere in this thread that \r and \n have reversed semantics on the Mac (vs. *nix, Windows).

    Um, no, that statement hasn't been made on this thread.

    Oh yes it has. On a Mac, "\n" is "\015" (native end-of-lines), and "\r" is the other one, "\012". The sequences you can encounter, in Ascii, are matched by /\015\012|\015|\012/.

    In addition, "\015\015\012" can occur too, in HTML pages you can download from the web, because of an erroneous FTP upload from Windows to Unix, as binary — and a download as text, which adds another CR.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://198149]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2024-04-18 15:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found