In addition to the other comments, I think when you're getting the state setting from the form, you mean to say $FORM{state}; you currently say $FORM{$state}, and since $state isn't defined yet, you're looking at $FORM{''}. Using warnings would have told you that, BTW.
And I suspect you don't know how to use a lookup table, since this is the perfect application for one. Essentially you would say:
As you can see, the code is much cleaner and easier to maintain, and will also be marginally faster in most cases.%states = ( AL => ['AL', 'Alabama'], AK => ['AK', 'Alaska'], ... SA => ['SA', 'Saskatchewan'], YU => ['YU', 'Yukon Territory'], ); if (my $st = $states{$FORM{state}}) { ($state,$statename)=@$st; } else { die "Invalid state!" }
In reply to Re: Untaint variables not working, IF statements.
by sgifford
in thread Untaint variables not working, IF statements.
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |