Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Disable warnings from specific module

Reply
Thread Tools

Disable warnings from specific module

 
 
snunes@gmail.com
Guest
Posts: n/a
 
      02-27-2007
Hi,

I'm using a module with a couple of experimental features (SOAP::Lite)
and, every time these features are used, a warning message is
outputted. I would like to know how can I simply disable these outputs
while keeping warnings for my code?

use strict;
use warnings;

use SOAP::Lite;

[...]

Thanks in advance,
SÚrgio Nunes

 
Reply With Quote
 
 
 
 
Paul Lalli
Guest
Posts: n/a
 
      02-27-2007
On Feb 27, 11:38 am, (E-Mail Removed) wrote:

> I'm using a module with a couple of experimental features
> (SOAP::Lite) and, every time these features are used, a warning
> message is outputted. I would like to know how can I simply
> disable these outputs while keeping warnings for my code?


You could try wrapping a call to any of those experimental features in
a block in which $SIG{__WARN__} has been changed to ignore warnings.
Or you could try locally setting $^W to 0 in a block around those
features (though I don't think that would handle the case where the
module's code is specifically generating a warning using the warn()
function).

{
local $SIG{__WARN__} = sub { 1 };
do_something_experimental();
}

Hope that helps,
Paul Lalli

 
Reply With Quote
 
 
 
 
Mark Clements
Guest
Posts: n/a
 
      02-27-2007
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> Hi,
>
> I'm using a module with a couple of experimental features (SOAP::Lite)
> and, every time these features are used, a warning message is
> outputted. I would like to know how can I simply disable these outputs
> while keeping warnings for my code?
>
> use strict;
> use warnings;
>
> use SOAP::Lite;
>


I would have expected this to have worked:

mark@owl:~$ cat AA.pm
package AA;

use strict;
use warnings;

sub testsub {
my $test;
print "$test\n";

}

1;
mark@owl:~$ cat testaa.pl
use strict;
use warnings;

use AA;

{
package AA;
use warnings::register;
}
no warnings q(AA);

AA::testsub();
mark@owl:~$ perl testaa.pl
Use of uninitialized value in concatenation (.) or string at AA.pm line 8.

but it doesn't surpress the warning message, although adding

use warnings::register;

to AA.pm has the desired effect.

Mark
 
Reply With Quote
 
comp.llang.perl.moderated
Guest
Posts: n/a
 
      03-02-2007
On Feb 27, 11:52 am, "Paul Lalli" <(E-Mail Removed)> wrote:
> On Feb 27, 11:38 am, (E-Mail Removed) wrote:
>
>....
>
> You could try wrapping a call to any of those experimental features in
> a block in which $SIG{__WARN__} has been changed to ignore warnings.
> Or you could try locally setting $^W to 0 in a block around those
> features (though I don't think that would handle the case where the
> module's code is specifically generating a warning using the warn()
> function).
>
> {
> local $SIG{__WARN__} = sub { 1 };
> do_something_experimental();
>
> }


Ugly but you could filter stderr entirely...
I think:


open( SAVE, '>&STDERR') or die $!;
{ open(STDERR, '>', File::Spec->devnull);
do_something_experimental();
}
open( STDERR, '>&SAVE' ) or die $!;
....

--
Charles DeRykus

 
Reply With Quote
 
comp.llang.perl.moderated
Guest
Posts: n/a
 
      03-02-2007
On Mar 1, 10:15 pm, "comp.llang.perl.moderated" <c...@blv-
sam-01.ca.boeing.com> wrote:
> On Feb 27, 11:52 am, "Paul Lalli" <(E-Mail Removed)> wrote:
>
>
>
> > On Feb 27, 11:38 am, (E-Mail Removed) wrote:

>
> >....

>
> > You could try wrapping a call to any of those experimental features in
> > a block in which $SIG{__WARN__} has been changed to ignore warnings.
> > Or you could try locally setting $^W to 0 in a block around those
> > features (though I don't think that would handle the case where the
> > module's code is specifically generating a warning using the warn()
> > function).

>
> > {
> > local $SIG{__WARN__} = sub { 1 };
> > do_something_experimental();

>
> > }

>
> Ugly but you could filter stderr entirely...
> I think:
>
> open( SAVE, '>&STDERR') or die $!;
> { open(STDERR, '>', File::Spec->devnull);
> do_something_experimental();}
>
> open( STDERR, '>&SAVE' ) or die $!;
> ...
>


Sorry, my suggestion is really dumb the more I think about it.. You
might lose a fatal message from SOAP::Lite for instance. I'm not
sure why setting SIG{__WARN__} or even $^W locally wouldn't do
what's needed. The 'warnings' pragma would be better than the
global $^W however. A 'no warnings "blah.." for example could just
filter out the specific nuisance warning(s) whiile leaving other
unexpected errors intact. perldoc warnings.

--
Chales DeRykus

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I disable warnings? Grant Edwards Python 2 09-10-2007 09:01 PM
how do I disable Firefox security warnings? trevor_smithson@yahoo.com Firefox 2 07-25-2006 12:29 PM
ruby 1.8.4 gives warnings where ruby 1.8.2 doesn't - how to disable? Asfand Yar Qazi Ruby 1 03-19-2006 11:09 AM
use warnings; and use Warnings; give different results Ted Sung Perl Misc 1 08-30-2004 10:22 PM
How to disable debugger-related warnings!?! Jason Heyes C++ 3 12-09-2003 08:00 PM



Advertisments