in reply to Re: How to stack a call to a class method
in thread How to stack a call to a class method

I can't think of any code that actually uses warnings::warn() at all...

% cd /usr/local/lib/perl5 % find . -type f -exec grep -l 'warnings::warn' {} \; ./5.8.0/alpha-dec_osf/DB_File.pm ./5.8.0/alpha-dec_osf/Socket.pm ./5.8.0/alpha-dec_osf/IO/Select.pm ./5.8.0/charnames.pm ./5.8.0/constant.pm ./5.8.0/open.pm ./5.8.0/overload.pm ./5.8.0/syslog.pl ./5.8.0/vars.pm ./5.8.0/warnings.pm ./5.8.0/Tie/Handle.pm ./5.8.0/Tie/Hash.pm ./5.8.0/Tie/Scalar.pm ./5.8.0/I18N/Collate.pm ./5.8.0/File/Find.pm ./5.8.0/Class/Struct.pm ./5.8.0/pod/perllexwarn.pod ./5.8.0/pod/perltoc.pod
Not an overwhelmingly large list, but there are a few modules.

blyman
setenv EXINIT 'set noai ts=2'

Replies are listed 'Best First'.
Re: Re: Re: How to stack a call to a class method
by demerphq (Chancellor) on Mar 04, 2003 at 09:23 UTC

    Yes true. And in fact if you had done a search on warnings::warnif() you probably would have found many more hits. Thanks for the correction.

    Although I didnt articulate this, what I was thinking of was that all output from warnings.pm are reported through CORE::warn() and CORE::die() (via Carp.pm) so overriding them (globally) or setting $SIG{__WARN__} and $SIG{__DIE__} to preprocess their arguments should resolve all user generated messages. The latter actually allows you to intercept Perl generated exceptions. Although in the case of a die() that won't be useful for much beyond changing the error message.

    ---
    demerphq


      ++demerphq

      Thanks for the update. Yesterday a co-worker asked me how to turn off warnings that a module was generating during the course of his testing. (The warnings were of the sort "warning, you're running in test mode, DB will not be updated")

      During the test, he doesn't want to see the warnings. But during a live run, he would want to see them show up in the log. We played around unsuccessfully with having the test program install a new warnings::warn, CORE::warn, and even installing a warn in the package that was being tested. No dice.

      $SIG{__WARN__} sounds like exactly what we want; I'll have to hit that bit of the cookbook a bit more ;)

      blyman
      setenv EXINIT 'set noai ts=2'