[Israel.pm] newline character as a portability issue

Shlomo Yona shlomo at cs.haifa.ac.il
Wed Jul 7 22:59:51 PDT 2004


On Thu, 8 Jul 2004, Dovalle Yankelovich wrote:

> Another solution, which will work only if you first read a file with
> return new line on a machine and manipulate it to work on same machine,
> is 
> $file =~ s(\015\012?|\012){\n}g;

This suggest that a newline can be either
	\015
or
	\012
or
	\015\012

how can I be sure that there aren't more possibilities?

This also alters the text and still doesn't tell me for sure
what is the expected newline character or sequence of
characters...

looking at perldoc perlport I see:

	LF  eq  \012  eq  \x0A  eq  \cJ  eq  chr(10)  eq ASCII 10
	CR  eq  \015  eq  \x0D  eq  \cM  eq  chr(13)  eq ASCII 13

	     | Unix | DOS  | Mac  |
	---------------------------
	\n   |  LF  |  LF  |  CR  |
	\r   |  CR  |  CR  |  LF  |
	\n * |  LF  | CRLF |  CR  |
	\r * |  CR  |  CR  |  LF  |
	---------------------------
	* text-mode STDIO

Perhaps you're right and I should perhaps use a fuzzy
newline pattern...

I'm still confused...

-- 
Shlomo Yona
shlomo at cs.haifa.ac.il
http://cs.haifa.ac.il/~shlomo/



More information about the Perl mailing list