note
rovf
<blockquote><i>
</i></blockquote>
Astonishing.
<p>
Well, now I have learned that explicitly setting the <c>:unix</c> layer is, depending on the situation, either evil or useless, I have to say that I indeed <b>found</b> a case where it seems to work in the way I originally intended: When it comes to creating a file, and we leave out the possibilities I mentioned, and the ones you added, and write it in the :unix layer way, i.e.
<code>
use strict;
use warnings;
open(my $fh,'>:unix','abc.txt') or die $!;
print $fh "one line\n"
</code>
we find that, after running this program on Windows, the line terminator of the file is LF (not CRLF). Different to reading a file, :unix layer seems to make sense here.
Even unlinking the file works:
<c>
use strict;
use warnings;
open(my $fh,'>:unix','abc.txt') or die $!;
print $fh "one line\n"
close $fh;
# No error message on unlink
unlink 'abc.txt' or die $!;
</c>
However, this works only if we don't use <c>binmode</c> for setting the layer. The following fails:
<c>
use strict;
use warnings;
open(my $fh,'>','abc.txt') or die $!;
binmode($fh,':unix');
print $fh "one line\n"
close $fh;
# Error message on unlink
unlink 'abc.txt' or die $!;
</c>
This confirms the theory that the problem is not the setting of the :unix layer as such, nor the use of binmode for setting a layer, but the combination of both. Indeed, if we replace in the last example :unix by, say, :crlf or :raw, we don't get an error message.
</p>
<div class="pmsig"><div class="pmsig-683288">
-- <br>
Ronald Fischer <ynnor@mm.st>
</div></div>
1039307
1039345