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.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|