First my code
$search = $top->Entry ('-width' => 20,
) ->pack('-side' => 'left');
$search->bind('<KeyPress-Return>', \&search);
sub search
{
SEARCH_GET:
my ($search_pattern , $string );
$search_pattern = $search->get();
print "Pattern entered into Search-box is: $search_pattern\n "
+;
(goto SEARCH_GET) if (! (defined $search_pattern) ); # if <RET>
+ is entered by itself, then ignore it...
if ( $search_pattern =~ /^([\w\s\-\:\_\d]+)$/ ) ## CHECK $sea
+rch_pattern and untaint:
{ ## make sure it onl
+y contains \w, '-' , ':' , '_' , and digits
$string = $1; ## DON'T forget
+ 's -- space between prog and $arg
print "\$string is untainted; \$string = $string \n ";
}
else
{
print "OOPS! data is tainted. TRY AGAIN...\n ";
}
.
.
.
}
If the first char I enter into the search-box is <RET>, then the program freezes.
BESIDES. What was entered? Was it \n or " " or undef?
How do I catch a carriage-return that was entered by itself , and thus prevent the
programs freezup?