in reply to Re: diagnostics, STDERR, and codepage conversions (TFM)
in thread diagnostics, STDERR, and codepage conversions

Ok, I've been pouring over this trying to figure out what you're referring to. Reading my local docs on open, I don't see any open examples that don't use typeglobs (well, one uses a lexical, the rest use typeglobs). Further, I'm redirecting STDERR - a typeglob. I am not introducing new typeglobs (other than a localised version of STDERR), and am attempting to keep anyone from using that global. So I'm not sure how it's relevant to cleaning up the hack anyway - I'm trying to modify a built-in typeglob, so I think I pretty much have to use that typeglob.

Second, I'm not sure how your help is related to the questions I actually had. I suspect that you didn't intend to answer those, but unless I can be sure about your intentions, I have to assume you may have had a gem in there that I'm currently unable to grasp that would help my codepage conversions (whose code I didn't show, I conceded I couldn't boil it down yet, and doesn't use typeglobs at all).

So I'm a bit confused. Any clarification would be helpful.

  • Comment on Re^2: diagnostics, STDERR, and codepage conversions

Replies are listed 'Best First'.
Re^3: diagnostics, STDERR, and codepage conversions (open)
by tye (Sage) on Aug 13, 2007 at 21:43 UTC

    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        

      Ok, much more clear now, thanks. Just FYI - the reason why I didn't believe it is because I learned that idiom here ;-) e.g., an article by our own merlyn. Ok, that's not specifically here... but it's a site I only learned about from perlmonks. And the author is rumoured to be reasonably proficient... :-> (Ok, appeal to authority - he could be wrong about some stuff, even in his specialty.) Then, [id://3989;BIT=local *STDERR;BIS=%3B] shows ikegami using it without comment on style (perhaps you just missed them at the time). So I plead educated ignorance - the masters were doing it, so I thought it was a good idea ;-)

      Just to continue with the thread drift (though I still would like someone to answer the original questions if they have any help), I'm wondering why they suck. As in, what way? Is it an accidental feature that could be removed from 5.10 or something?

      And I found (remembered) another way to kill the messages without redirecting, which is better since it will be much more specific: set the __WARN__ handler to ignore the warning, and that will keep the diagnostics from being hit (since it's a __WARN__ handler, too):

      my $oldwarn = $SIG{__WARN__}; local $SIG{__WARN__} = sub { my ($msg) = @_; if ($msg =~ /utf8_heavy/) { # do nothing } elsif ($oldwarn) { goto &$oldwarn if $oldwarn; } else { warn @_; } };
      And now I don't need to redirect, but I'm still interested in it.