in reply to Supressing warnings
but surprisingly it doesn't - this emits warnings. Why is that?
My guess is that this has the same scope problems that no warnings 'deprecated' has.
It seems the -X of the shebang-line takes effect even though you explicitly invoke perl on the command line. Is that so?
From DESCRIPTION in perlrun:
The #! line is always examined for switches as the line is being parsed.
Finally I would be interested if there is a way to globally disable specifically the deprecation warnings only.
I'm hoping someone can offer up a more elegant solution, as the following seems a little fragile/hackish. In order to filter out deprecation warnings, I've put in a BEGIN block with a second internal block with a localized WARN handler. Since perl compiles each module at most one time, this catches the emitted warnings on the first compile. The regular expression then filters out any newline-delimited portion of the emitted warnings that contain the word deprecated. Note that swapping from a require to a use will make the following code fail to catch the warnings, at least on my machine.
BEGIN { my $initial_warnings = ""; { local $SIG{__WARN__} = sub{$initial_warnings .= $_[0]}; require Foo; } $initial_warnings =~ s/^.*deprecated.*$ \n?//xmg; warn $initial_warnings if $initial_warnings; } use Foo;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Supressing warnings
by morgon (Priest) on Jul 22, 2010 at 21:22 UTC | |
by almut (Canon) on Jul 22, 2010 at 21:39 UTC | |
by morgon (Priest) on Jul 22, 2010 at 23:27 UTC | |
by almut (Canon) on Jul 23, 2010 at 00:14 UTC | |
by morgon (Priest) on Jul 22, 2010 at 23:41 UTC | |
by Boldra (Deacon) on Jul 23, 2010 at 07:10 UTC |
In Section
Seekers of Perl Wisdom