let's say i have fields for 9 scores and 9 putts. i need to check each of these to be sure they're numeric or blank. if a field is blank, i want to change it to zero. then i need to compare the putts to the score to be sure the score is always greater than putts. i have tried a zillion things but cannot get it to work! i'm incrementing the scores in $in{"fs$k"} and putts in $in{"fp$k"} where k increments from 1 to 9. here is excerpt of my code:
while ($k < 10 ) {
$in{"fs$k"} =~ s/\s+$//g;
if (!$in{"fs$k"}) {$in{"fs$k"} = '0'; }
...
if (($in{"fs$k"} =~ /^[0-9]+$/) || ($in{"bs$k"} =~ /^[0-9]+$/)) { $score = 'Scores (must be numeric)<br>'; }
if (($in{"fp$k"} =~ /^[0-9]+$/) || ($in{"bp$k"} =~ /^[0-9]+$/)) { $putt1 = 'Putts (must be numeric)<br>'; }
if (($in{"fp$k"} > $in{"fs$k"}) || ($in{"bp$k"} > $in{"bs$k"})) { $putt2 = 'Putts (must be less than score)<br>'; }
++$k;
}i keep getting the message that scores and putts must be numeric, even when i type numbers in every field and my putts are less than scores. please help!
Code:
my ($k) = 1; while ($k < 10 ) {
$in{"fs$k"} =~ s/\s+$//g;
if (!$in{"fs$k"}) {$in{"fs$k"} = '0'; }
...
if (($in{"fs$k"} =~ /^[0-9]+$/) || ($in{"bs$k"} =~ /^[0-9]+$/)) { $score = 'Scores (must be numeric)<br>'; }
if (($in{"fp$k"} =~ /^[0-9]+$/) || ($in{"bp$k"} =~ /^[0-9]+$/)) { $putt1 = 'Putts (must be numeric)<br>'; }
if (($in{"fp$k"} > $in{"fs$k"}) || ($in{"bp$k"} > $in{"bs$k"})) { $putt2 = 'Putts (must be less than score)<br>'; }
++$k;
}