note
sauoq
<blockquote><em>
Besides using a table to infer it from $^O, is there any other way to detect it?
</em></blockquote>
<p>It's not neat, but you can actually write a newline to a file and then read it in binmode:
<code>
use warnings;
use strict;
open FH, '>', 'out.txt' or die $!;
print FH "\n";
close FH;
open FH, '<', 'out.txt' or die $!;
binmode(FH);
my $stuff = do { local $/; <FH> };
print unpack('H*', $stuff), "\n";
</code></p>
<p>Tested on Windows, where it prints <c>0d0a</c> and on Linux where it prints <c>0a</c>.</p>
<p>You could clean it up, use [cpan://File::Temp]... whatever. But, unfortunately, you can't get by with an in memory file or [cpan://IO::Scalar].</p>
<div class="pmsig"><div class="pmsig-182681">
<tt>
-sauoq<br />
"My two cents aren't worth a dime.";<br />
</tt>
</div></div>
971815
971815