package L; use warnings; use strict; use Devel::StackTrace; our $DYING = 0; sub include { my $file = shift; unless (my $return = do $file) { my $e; if ($@) { $e = "Couldn't parse $file: $@" } elsif (!defined $return) { $e = "Couldn't do $file: $!\n" } elsif (!$return) { $e = "Couldn't run $file\n" } if ($e) { # don't add a new stack trace if we're already dying die $@ if $DYING++; die join '', $e, map {"\t".$_->as_string."\n"} Devel::StackTrace->new(ignore_package=>__PACKAGE__)->frames; } } } 1; #### Couldn't parse X.pm: Blammo at X.pm line 9. L::include('X.pm') called at B.pm line 8 L::include('B.pm') called at A.pm line 9 A::load_b('foo') called at A.pm line 11 L::include('A.pm') called at test.pl line 8