title: restart multi-threaded perl script and close mysql connection
body: <p>I have a Perl script that reads a command file and restarts itself if necessary by doing:</p>
  
  <p>myscript.pl:</p>
  
  <pre><code>exec '/home/foo/bin/myscript.pl';
  exit(0);
  </code></pre>
  
  <p>Now, this works fine except for one issue. The thread that reads the command file does not have access to the DBI handle I use. And over a number of restarts I seem to build up the number of open mysql connections till I get the dreaded "Too Many Connections" error. The DBI spec says:</p>
  
  <p><em>"Because of this (possibly temporary) restriction, newly created threads must make their own connections to the database. Handles can't be shared across threads."</em></p>
  
  <p>Any way to close connections or perhaps a different way to restart the script?</p>