open gives examples of how to save, redirect, and restore file handles. That example does not do things the way you did. Yes, doing it the wrong way is why your code isn't redirecting correctly. Yes, that was the question you asked that I was addressing. No, I had no comment on your second question.

The open examples (implicitly) pass typeglobs as arguments to open(). They don't use any typeglob syntax, not a single use of * except in some example regular expressions). They don't manipulate typeglobs directly in hopes of having a similar impact on the file handles contained in them.

Rephrased more clearly and more correctly: Don't copy, save, or restore typeglobs that contain open file handles.

And, of course, when the standard documentation shows how to do something, it is often a good idea to pay attention.

I am not introducing new typeglobs (other than a localised version of STDERR)

Yep, you even figured out which one I'm talking about, but refused to belive it? :)

If it was a good idea to save/restore a file handle with a simple local(*STDERR), do you think the example of how to save/restore a file handle in the standard open docs would have avoided such?

- tye        


In reply to Re^3: diagnostics, STDERR, and codepage conversions (open) by tye
in thread diagnostics, STDERR, and codepage conversions by Tanktalus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.