Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Description in perlport of the meaning of \n #9670

Closed
p5pRT opened this issue Mar 3, 2009 · 6 comments
Closed

Description in perlport of the meaning of \n #9670

p5pRT opened this issue Mar 3, 2009 · 6 comments

Comments

@p5pRT
Copy link

p5pRT commented Mar 3, 2009

Migrated from rt.perl.org#63620 (status was 'resolved')

Searchable as RT63620$

@p5pRT
Copy link
Author

p5pRT commented Mar 3, 2009

From mail@gunnar.cc

This is a bug report for perl from mail@​gunnar.cc,
generated with the help of perlbug 1.36 running under perl 5.10.0.


The second para in the Newlines section of perlport.pod describes
the meaning of \n. As regards "DOSish perls", the description is
not clear IMO. In a discussion at comp.lang.perl.misc, Ben Morrow
suggested a changed wording​:

Inline Patch
--- /usr/lib/perl5/5.10.0/pod/perlport.pod      2008-04-18 22:48:31.000000000 -0400
+++ perlport.pod        2009-03-03 13:21:21.000000000 -0500
@@ -88,11 +88,11 @@

 Perl uses C<\n> to represent the "logical" newline, where what is
 logical may depend on the platform in use.  In MacPerl, C<\n> always
-means C<\015>.  In DOSish perls, C<\n> usually means C<\012>, but
-when accessing a file in "text" mode, STDIO translates it to (or
-from) C<\015\012>, depending on whether you're reading or writing.
-Unix does the same thing on ttys in canonical mode.  C<\015\012>
-is commonly referred to as CRLF.
+means C<\015>.  In DOSish perls, C<\n> means C<\012>, but when
+accessing a file, by default a :crlf layer is pushed which will
+result in C<\015\012> appearing in the file.  Unix does the same
+thing on ttys in canonical mode.  C<\015\012> is commonly referred to
+as CRLF.

 To trim trailing newlines from text lines use chomp().  With default
 settings that function looks for a trailing C<\n> character and thus

-----------------------------------------------------------------
---
Flags:   category=docs   severity=medium

Site configuration information for perl 5.10.0​:

Configured by root at Sat Apr 19 00​:09​:44 EDT 2008.

Summary of my perl5 (revision 5 version 10 subversion 0) configuration​:
  Platform​:
  osname=linux, osvers=2.6.12.4-vs2.0, archname=i686-linux
  uname='linux gunnar.cc 2.6.12.4-vs2.0 #9 smp fri nov 11 23​:37​:46 est 2005 i686 i686 i386 gnulinux '
  config_args=''
  hint=recommended, useposix=true, d_sigaction=define
  useithreads=undef, usemultiplicity=undef
  useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
  use64bitint=undef, use64bitall=undef, uselongdouble=undef
  usemymalloc=n, bincompat5005=undef
  Compiler​:
  cc='cc', ccflags ='-fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
  optimize='-O2',
  cppflags='-fno-strict-aliasing -pipe -I/usr/local/include -I/usr/include/gdbm'
  ccversion='', gccversion='3.3.2 20031022 (Red Hat Linux 3.3.2-1)', gccosandvers=''
  intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
  ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
  alignbytes=4, prototype=define
  Linker and Libraries​:
  ld='cc', ldflags =''
  libpth=/usr/lib
  libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc
  perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
  libc=/lib/libc-2.3.2.so, so=so, useshrplib=false, libperl=libperl.a
  gnulibc_version='2.3.2'
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
  cccdlflags='-fPIC', lddlflags='-shared -O2'

Locally applied patches​:
 


@​INC for perl 5.10.0​:
  /usr/lib/perl5/5.10.0/i686-linux
  /usr/lib/perl5/5.10.0
  /usr/lib/perl5/site_perl/5.10.0/i686-linux
  /usr/lib/perl5/site_perl/5.10.0
  /usr/lib/perl5/site_perl/5.8.1
  /usr/lib/perl5/site_perl
  .


Environment for perl 5.10.0​:
  HOME=/home/gunnarh
  LANG (unset)
  LANGUAGE (unset)
  LD_LIBRARY_PATH (unset)
  LOGDIR (unset)
  PATH=/usr/kerberos/bin​:/usr/local/bin​:/bin​:/usr/bin​:/usr/X11R6/bin​:/home/gunnarh/bin
  PERL_BADLANG (unset)
  SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Mar 4, 2009

From @tamias

On Tue, Mar 03, 2009 at 10​:56​:55AM -0800, Gunnar Hjalmarsson wrote​:

The second para in the Newlines section of perlport.pod describes
the meaning of \n. As regards "DOSish perls", the description is
not clear IMO. In a discussion at comp.lang.perl.misc, Ben Morrow
suggested a changed wording​:

--- /usr/lib/perl5/5.10.0/pod/perlport.pod 2008-04-18 22​:48​:31.000000000 -0400
+++ perlport.pod 2009-03-03 13​:21​:21.000000000 -0500
@​@​ -88,11 +88,11 @​@​

Perl uses C<\n> to represent the "logical" newline, where what is
logical may depend on the platform in use. In MacPerl, C<\n> always
-means C<\015>. In DOSish perls, C<\n> usually means C<\012>, but
-when accessing a file in "text" mode, STDIO translates it to (or
-from) C<\015\012>, depending on whether you're reading or writing.
-Unix does the same thing on ttys in canonical mode. C<\015\012>
-is commonly referred to as CRLF.
+means C<\015>. In DOSish perls, C<\n> means C<\012>, but when
+accessing a file, by default a :crlf layer is pushed which will
+result in C<\015\012> appearing in the file. Unix does the same
+thing on ttys in canonical mode. C<\015\012> is commonly referred to
+as CRLF.

To trim trailing newlines from text lines use chomp(). With default
settings that function looks for a trailing C<\n> character and thus

I find that this new text is less clear than the original. In particular,
what does it mean for C<\015\012> to "appear in a file" that is being read,
not written?

Ronald

@p5pRT
Copy link
Author

p5pRT commented Mar 4, 2009

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Mar 4, 2009

From mail@gunnar.cc

Ronald J Kimball via RT wrote​:

On Tue, Mar 03, 2009 at 10​:56​:55AM -0800, Gunnar Hjalmarsson wrote​:

The second para in the Newlines section of perlport.pod describes
the meaning of \n. As regards "DOSish perls", the description is
not clear IMO. In a discussion at comp.lang.perl.misc, Ben Morrow
suggested a changed wording​:

--- /usr/lib/perl5/5.10.0/pod/perlport.pod 2008-04-18 22​:48​:31.000000000 -0400
+++ perlport.pod 2009-03-03 13​:21​:21.000000000 -0500
@​@​ -88,11 +88,11 @​@​

Perl uses C<\n> to represent the "logical" newline, where what is
logical may depend on the platform in use. In MacPerl, C<\n> always
-means C<\015>. In DOSish perls, C<\n> usually means C<\012>, but
-when accessing a file in "text" mode, STDIO translates it to (or
-from) C<\015\012>, depending on whether you're reading or writing.
-Unix does the same thing on ttys in canonical mode. C<\015\012>
-is commonly referred to as CRLF.
+means C<\015>. In DOSish perls, C<\n> means C<\012>, but when
+accessing a file, by default a :crlf layer is pushed which will
+result in C<\015\012> appearing in the file. Unix does the same
+thing on ttys in canonical mode. C<\015\012> is commonly referred to
+as CRLF.

To trim trailing newlines from text lines use chomp(). With default
settings that function looks for a trailing C<\n> character and thus

I find that this new text is less clear than the original. In particular,
what does it mean for C<\015\012> to "appear in a file" that is being read,
not written?

Ok, I see what you mean. It was taken directly from this message​:

http​://groups.google.com/group/comp.lang.perl.misc/msg/7d6ca2e5eef111c5

Then how about​:

In DOSish perls, C<\n> means C<\012>. When reading a file in "text"
mode, a :crlf layer is pushed which translates C<\015\012> to C<\012>.
The reverse translation takes place when saving in "text" mode which
results in C<\015\012> appearing in the file.

Best regards,

Gunnar

@p5pRT
Copy link
Author

p5pRT commented Sep 24, 2009

From @briandfoy

Fixed by commit 51d9476

@p5pRT
Copy link
Author

p5pRT commented Mar 14, 2010

@iabyn - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant