[Israel.pm] newline character as a portability issue
margol at beamartyr.net
Thu Jul 8 03:22:45 PDT 2004
And what of MAC users, who have no "special" perl distro, and use just \r?
----- Original Message -----
From: "Alex Behar" <alex-b at actcom.net.il>
To: "Perl in Israel" <perl at perl.org.il>
Sent: Thursday, July 08, 2004 1:18 PM
Subject: Re: [Israel.pm] newline character as a portability issue
> On Wednesday 07 July 2004 19:27, Shlomo Yona wrote:
> > Hello,
> > I have a script which does some manipulation to texts.
> > This script assumes that '\n' is the newline character.
> > I wonder how I can make the script more robust across
> > platforms, regarding newline characters.
> > I know that on unices that '\n' is the newline. I don't
> > really know if that is always the case, and I also don't
> > know what happens on other platforms.
> > What would be a good way to attack this issue?
> > Once I have a solution, what would be the way to write tests
> > (using Test::More) to ensure that during installation (say,
> > during 'make test')? I mean, how can I make a platform
> > dependent test for this issue?
> > Thanks.
> Perl using just "\n" is portable enough. Meaning, if it's an active-perl
> installation, it will match the windows style line termination. If its a
> perl, it will match the UNIX newline.
> If you run a file made on a windows machine, and you try to match the new
> lines in a UNIX perl installation, it will work. I have not tested the
> from UNIX to windows, I dont have a windows box handy.
> Best regards,
> Perl mailing list
> Perl at perl.org.il
More information about the Perl