http://www.perlmonks.org?node_id=982888

shortyfw06 has asked for the wisdom of the Perl Monks concerning the following question:

I am trying to stop the execution of code when an error is found. I have "error" subroutines for example.

sub lam_num_error { $mw->messageBox(-message=>"The input must be an integer."); exit; }

The exit command is exiting the program completely which is not what I want. I've also tried this.

sub lam_num_error { $mw->messageBox(-message=>"The input must be an integer."); die; }

Using die seems to stop the execution of code but still keep the main window on the screen, which is what I want. However, I'm getting some errors like this.

Tk::Error: Died at Fastenator_working.pl line 1106. main::fl_num_error at Fastenator_working.pl line 1106 main::calc_fast_loads at Fastenator_working.pl line 1096 main::run_button at Fastenator_working.pl line 815 Tk callback for .frame13.button Tk::__ANON__ at C:/MSC.Software/Patran/2008_r2/Perl_msc/site/lib/Tk.p +m line 247 Tk::Button::butUp at C:/MSC.Software/Patran/2008_r2/Perl_msc/site/lib +/Tk/Button .pm line 111 <ButtonRelease-1> (command bound to event)

I'm not comfortable with these errors even though the code is still doing what I want. Can someone explain this and possibly suggest the best way to achieve my goal? I want the code to stop, let the user make some modifications to the input in the main window and then try again without completely shutting down the program. Thank you in advance!