Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Stopping bad input (harder than sanitizing)

by jcb (Parson)
on Mar 09, 2021 at 00:20 UTC ( [id://11129357] : note . print w/replies, xml ) Need Help??


in reply to Stopping bad input (harder than sanitizing)

Your immediate problem is simple: sub search goes into an infinite loop if $search_pattern is undefined. Instead of a goto, simply return early, as in return unless defined $search_pattern; which will cause the Tk event loop to resume and the UI to wait for the user to try again.