use strict; use warnings; BEGIN { $SIG{__WARN__} = sub { my $warning = shift; if ( $warning =~ m{\s at \s \S+ \s line \s \d+ \. $}xms ) { $DB::single = 1; # debugger stops here automatically } warn $warning; }; return; } my $undefined_scalar; print "Scalar has this value: $undefined_scalar, \n"; print "end\n";