http://qs1969.pair.com?node_id=521318

BillSeurer has asked for the wisdom of the Perl Monks concerning the following question:

The following bit of code writes "yadda yadda" into a file via a redirected STDOUT. If STDOUT is not closed first the :encoding on the open is ignored (with Perl 5.8.6).
my $fooFile = "foo.out"; unlink $fooFile; #close STDOUT; # with this it works open STDOUT, ">>:encoding(cp37)", $fooFile or die "Cannot redirect STD +OUT\n"; select(STDOUT); $| = 1; print "yadda yadda\n"; close STDOUT;

Is this working as expected or should it work without the close() in there?

I had the person who found this add close()s so it's no big deal but I am just curious as to what is correct.