in reply to Make select apply to modules as well

Are you sure? This seems to work for me:
% perl -le 'select STDERR; f::f(); package f; sub f { print "Now you s +ee me" }' > /dev/null Now you see me % perl -le 'f::f(); package f; sub f { print "Now you don'\''t" }' > / +dev/null (nothing)

Replies are listed 'Best First'.
Re^2: Make select apply to modules as well
by richz (Beadle) on Dec 05, 2004 at 20:38 UTC
    Yeah, it's not working for me. Seems weird.
      Please write a small sample of code that you think should work yet doesn't. If the situation is as you describe, then I'll wind up suggesting that you use the perlbug utility to report a bug in Perl.

      However I strongly suspect that you're missing something, and select works as it is documented. Perhaps select is called again, perhaps the messages you're complaining about come on STDERR thanks to warnings, perhaps a million things.

      But the vanishingly unlikely scenario is that you're encountering a bug in Perl. I don't mean to suggest that you're lying - we've all had the experience of being sure that Perl has a bug because we don't see how what we are seeing is possible otherwise. But, even still, this experience is almost always followed by a, "D'oh!"

        Ok, what is happening is that the default filehandle seems to be changed inside my module as it should UNTIL I make a call to another subroutine which does an in-place edit of a file.

        Does changing $^I(which I do for the in-place edit) screw anything up?

        Thanks.

        Tilly,

        I certainly don't mean to say there is a bug in Perl. I am sure I am doing something wrong but it is not at all obvious to me. I will do some more debug of my own and let you know. It is hard for me to post the code because it is a lot of code and I'd prefer not to do so unless I can't figure it out.

      Do these one-liners also not work for you?

      What's the code in the module? Are you certain it isn't doing select somewhere? (Can you post it?)

      What platform are you on?

        I am on Win32...I have no experience running perl code on the command line so I'm probably doing something wrong but I can't get your sample code to run.