in reply to Re^4: How do I replicate die's magic with $. ?
in thread How do I replicate die's magic with $. ?

If this is just for the error message, die (or Carp::croak, if deep in some library) will already inform your user of the relevant parts:

>perl -wle "open my $fh, 'makefile.pl'; <$fh>; die 'foo'" foo at -e line 1, <$fh> line 1.

I'm not sure where outside of dieing the information can be helpful, and if you are dieing, why not use what Perl uses? Also, die usually is a one-time thing, so I wouldn't worry about the performance aspect of capturing an exception just to get at more information, if that really is necessary.