{ local $SIG{__WARN__} = sub { my @warnings = @_; foreach my $warning (@warnings) { print "got a warning: $warning\n"; } }; eval {'' =~ /$re/ }; }