This PHP feature is crazy and should be avoided whenever possible.
Perl has two kinds of exceptions: fatal errors and warnings. Warnings can be issued either by Perl itself or by user code.
Within a specific static / lexical scope, Perl's built-in warnings can be disabled as follows:
use warnings;
foo();
sub foo {
no warnings 'uninitialized';
warn "hello\n";
1 + undef;
}
Exit: helloto STDERR.
( )
, ( ). .
__WARN__:
use warnings;
{
local $SIG{__WARN__} = sub { };
foo();
print "bye\n";
}
sub foo {
warn "hello\n";
1 + undef;
}
: bye STDOUT.
muffle:
sub muffle {
my $func = shift;
local $SIG{__WARN__} = sub { };
return $func->(@_);
}
muffle(\&foo, 1, 2, 3);
, :
, , , Try::Tiny.