you could do something like this if you wanted to restrict a field to a certain set. The @wrong array will contain all violating enteries (if you want them in your error msg.
my $test="%%6ffgg";
die("illegal character found".join(',',@wrong)."\n") if @wrong = $test
+ =~(m/([^a-zA-Z0-9])/g);
output
illegal character found%,%