use Carp; eval { die "Ouch" }; print $@, "\n"; __OUTPUT__ Ouch at C:\Perl\scripts\mytest.pl line 6.