Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Even when it comes to network protocols, "\r" and "\n" can be a better choice than "\012\015". In fact, the only reason this "\012\015" has become popular is the old Macintosh! If it weren't for that, then there would be no case where "\012\015" was a better choice.

Consider running Perl on an EBCDIC system (yes, there are such ports of Perl) trying to talk SMTP to send mail. You need to say "HELO\n" but try to be "portable" and say "HELO\012". You think the SMTP server you are talking to is going recognize "HELO" in EBCDIC?? Of course not. Which means that on an EBCDIC system talking over some socket emulation, you are going to be going through a EBCDIC/ASCII converting gateway and if you send "\012" through that from the EBCDIC side, it isn't going to reach the other side as "\n". You want "HELO\n".

It is sad that the old Mac mistakes have so confused people about what is portable code. "\012\015" is portable to the old Mac but is very specific to the near-ASCII nature of old Macs. Using such without first testing whether you are on a system where it works just indicates that you don't care about alternate character encodings. ASCII has become so popular that you can probably justify this sometimes.

But I find it silly that people proclaim how this makes their code more portable. It is just an old Mac thing. I'm not sure what non-ASCII environments Perl will end up running on; probably not very many. But hard-coding magic numbers is just not the way to go.

See Re^4: Line Feeds (rumor control) for if you want more on this. (:

                - tye

In reply to Re: \r\n vs \012\015 (tye) by tye
in thread An introduction to POE by RMGir

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2024-04-25 19:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found