This is the mail archive of the
cygwin@cygwin.com
mailing list for the Cygwin project.
Re: Perl 5.6.1: Problem with CRLF/LF conversions
- From: "Gerrit P. Haase" <gp at familiehaase dot de>
- To: Mikael Hubsch <mikael dot hubsch at tfstech dot com>
- Cc: cygwin at cygwin dot com
- Date: Tue, 6 Nov 2001 08:54:25 +0100
- Subject: Re: Perl 5.6.1: Problem with CRLF/LF conversions
- Organization: Esse keine toten Tiere
- References: <Pine.GSO.4.30.0211051354160.22446-100000@spirit.dynas.se>
- Reply-to: "Gerrit @ cygwin" <cygwin at cygwin dot com>
Hallo Mikael,
Am Dienstag, 5. November 2002 um 14:41 schriebst du:
> I'm trying to port a framework of perl scripts to cygwin. I'm running
> cygwin 1.3.14 on WinXP. The problem is that perl seems to assume binmode
> whenever I read a file, but text mode when I write to one.
> The sample code below shows the problem.
> If I write a line to a file with a LF-only ending, perl (or cygwin) adds a
> CR. When I later read the same line from the file the CR isn't removed.
> Is there some special option I need to set to make perl always assume text
> mode unless I explicitly use the binmode command?
> #!/usr/bin/perl -w
> open(F, "> foobar.txt") || die "Cannot create foobar.txt";
> print F "Line1\n";
> print F "Line2\n";
> close F;
> open(F, "< foobar.txt") || die "Cannot open foobar.txt";
> while (<F>) {
> s/(.)/sprintf("%02x ", ord($1))/ges;
> print "$_\n";
> }
> close F;
> exit 0;
Please consider to upgrade Perl to version 5.8,
click the 'Exp' radiobutton in setup.exe to load
down and install perl-5.8.0
Then you may play with the new PERLIO features,
please see: perldoc perlio for details.
Gerrit
--
=^..^=
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/