Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^2: Native newline encoding

by AnomalousMonk (Monsignor)
on May 23, 2012 at 00:04 UTC ( #971912=note: print w/ replies, xml ) Need Help??


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

Under Windoze 7:

>perl -wMstrict -le "my $fred; open O, '>', \$fred;; { local( $/, $\ ); print O \"\n\";; };; close O;; print unpack 'H*', $fred;; " 0a

I assume the result is the same on a *nix system. Anyone care to try the Mac?


Comment on Re^2: Native newline encoding
Download Code
Re^3: Native newline encoding
by Your Mother (Canon) on May 23, 2012 at 01:12 UTC
    …result is the same on a *nix system…

    You mean like a Mac? :P

    perl -le 'open F,">",\$f; {local($/,$\); print F "\n"}; print unpack " +H*", $f' 0a

      I'm not at all familiar with the Mac, but I had always heard/understood that it used 0x0d as the underlying OS-mumble-nix file system newline delimiter. No? (But that is separate and apart from the code experiments that have been done in this thread, since I suspect the delimiter is always 0x0a for Perl internally.)

        Mac has been a BSD / NeXTSTEP Unix variant called Darwin under the hood starting c 2000. I suspect some of its files/dev-UI may still use or default to legacy encoding schemes but so far I have been mercifully spared from needing to know.

Re^3: Native newline encoding
by BrowserUk (Pope) on May 23, 2012 at 04:40 UTC

    Sorry, I missed your reply due to all the noise created by my erstwhile friend.

    Under Windoze 7:

    My demo was also run under Windows (Vista), so no surprise there :)

    I assume the result is the same on a *nix system.

    Indeed. And that was exactly the point of the demonstration. salva's a *nix man and knows I'm a windows user; so the significance would not be lost on him.

    Anyone care to try the Mac?

    Since modern macs are essentially *nix, it'll be the same there also. You'd have to go back to MacOS to see a difference I think.


    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?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2014-08-23 20:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (178 votes), past polls