use strict; use warnings; eval { main(); }; if ($@) { print "Error in main(): $@\n"; # wait for input to stop script from finishing and terminal from closing ; } sub main { }