title: What's the best way to send an email if any error occurs in a Perl script?
body: <p>I am working on a script that does many things, and if at any point during its execution a 'die' gets executed or an error occurs, I'd like to send an email message to myself.</p>
  
  <p>I'm currently using the END block to check the exit status, and if it is greater than 0 call a error email subroutine, but I am wondering if there is a better way. The flaw with this current implementation is that if an error occurs in the email subroutine, an infinite loop will occur.</p>