Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^3: Native newline encoding

by BrowserUk (Pope)
on May 22, 2012 at 18:10 UTC ( #971843=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Native newline encoding
in thread Native newline encoding

It should be, for example, 0d0a on Windows ... I don't really do Windows

That's a bit obvious :)

It isn't perl(*) that writes the extra character; it is the C runtime (when writing to a data file opened as text). Those extra characters are also stripped by the CRT when reading -- assuming text mode.

If Perl added them itself, then the CRT would also do it and you'd end up with a real mess.

perl; and Perl programmers shouldn't need to concern themselves with the details, because -- unless they are reading text files in bin mode; which they shouldn't be -- the addition and removal of the 'extra characters' should be entirely transparent.

(*) ignoring PerlIO which does; but only because it bypasses the CRT and then emulates it -- the point of which mystifies me, but there it is.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?


Comment on Re^3: Native newline encoding
Re^4: Native newline encoding
by sauoq (Abbot) on May 22, 2012 at 18:34 UTC
    That's a bit obvious :)

    Erm... what's the obvious part? That I don't do Windows or that it should be 0d0a? Or both?

    He asked for the "native newline encoding of the OS"... It doesn't matter what writes it. Maybe it's because I don't do Windows but do have to deal the bastardized text files that come from Windows that the distinction is meaningless. I know I don't care whether it is Perl or the run time writing the characters. That they are there is what matters.

    -sauoq
    "My two cents aren't worth a dime.";
      He asked for the "native newline encoding of the OS"... It doesn't matter what writes it.

      Sorry mate! But it absolutely does matter.

      Which is why my post contains two questions which salva will get around to answering (or not) in his own time.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

      The start of some sanity?

        But it absolutely does matter.

        No, it doesn't. To be clear (because we could confuse others with what we are saying matters and doesn't if we continue along this line):

        I am saying it doesn't matter what writes the characters, only that they are there.

        While you are saying it doesn't matter that they are there because of what writes them.

        And, you know, this is what I hate about Windows... the pervasive attitude that the OS is doing something for you that you can just ignore.

        Here's an assignment that would illustrate the difference... You are to write a textual file with X lines. Each line will have Y number of characters not including the newline. X and Y will be determined at runtime. Before writing the file, tell the user how big it will be on disk.

        Update: Make it portable, of course.

        -sauoq
        "My two cents aren't worth a dime.";
Re^4: Native newline encoding
by sauoq (Abbot) on May 22, 2012 at 18:45 UTC

    Also, there are more OS's than *nix and Windows to worry about.

    -sauoq
    "My two cents aren't worth a dime.";
Re^4: Native newline encoding
by Anonymous Monk on May 22, 2012 at 19:09 UTC
    It isn't perl(*) that writes the extra character;

    (*) ignoring PerlIO which does;

    So, as nearly every modern perl out there has been built with PerlIO, your first statement is either talking about those ~0.01 percent which haven't, or you're saying that PerlIO doesn't belong to perl ... both of which seem pretty nonsensical to me.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://971843]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (8)
As of 2014-11-29 04:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (203 votes), past polls