Basically, using a generated temporary file from File::Temp was not giving the normal endings, but were "binary" by default.
Looking at the Perl code for File::Temp, I see that it uses sysopen rather than the normal open. I think that's why it behaves differently.use File::Temp; use File::Spec; print "hello1\n"; # defaults to CRLF, as documented. open F, ">", "out2.txt"; # ditto. print F "hello2\n"; open F, "> :utf8", "out3.txt"; # still CRLF print F "hello3\n"; open F, ">", "out4.txt"; binmode F, ":utf8"; # still OK! print F "hello4\x{b6}\n"; $h= new File::Temp( TEMPLATE => 'helloXXXXX', SUFFIX => $suffix, UNLIN +K => 0, DIR => File::Spec->tmpdir()); $fname= $h->filename; print "sending out5 to $fname\n"; # binmode $h, ":utf8"; # no CR, shows 0x0A only. But :utf8 silences +warning. print $h "hello5\x{b6}\n";
Why?
And why does sysopen not set up the platform defaults, though it still appears to use IO layers?
—John
Update: behavior on Perl 5.8.4 (ActiveState build 810), but is fixed in Perl 5.8.6 (AS build 811)
In reply to Why does File::Temp use sysopen? by John M. Dlugosz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |