Forcing list context on <$fh>

G

Gunnar Hjalmarsson

Ben said:
It's a little unclear, and of course the reference to STDIO is
incorrect. What it means is

In DOSish perls, "\n" means "\012", but when accessing a file by
default a :crlf layer is pushed which will result in "\015\012"
appearing in the file.

That sounds much better to me. I sent a bug report:

http://rt.perl.org/rt3/Public/Bug/Display.html?id=63620

(noted that the oldest open docs ticket is 8 years old...)
 
T

Tim McDaniel

Tim McDaniel said:
As a practical matter, I run enough scripts on Windows (whether
under bash or cmd) and have hit the problem enough that I do
chomp;
s/\r+$//;
as a matter of rote, or instead use \s if I want to strip all trailing
whitespace whatsoever.

Why not just

s/[\r\n]+$//;

in one operation and skip the chomp?

That would assume that $/ contains only carriage returns and ASCII
newlines (that is, not considering the "\n" special casing that gets
done when doing I/O on non-binary files). However, in practice for
me, $/ DOES contain only CR and NL.
 
G

Gunnar Hjalmarsson

Tim said:
Tim McDaniel said:
As a practical matter, I run enough scripts on Windows (whether
under bash or cmd) and have hit the problem enough that I do
chomp;
s/\r+$//;
as a matter of rote, or instead use \s if I want to strip all trailing
whitespace whatsoever.
Why not just

s/[\r\n]+$//;

in one operation and skip the chomp?

That would assume that $/ contains only carriage returns and ASCII
newlines (that is, not considering the "\n" special casing that gets
done when doing I/O on non-binary files).

What "\n" special casing?

http://groups.google.com/group/comp.lang.perl.misc/msg/932b35d8434e2f11
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top