in reply to Re: Need help with Validation script
in thread Need help with Validation script
#!/usr/bin/perl -w my @p_dlruom = ("EACH","FEET","FT","IN","UNIT"); my %validator = ( P_12MONTHDEMANDQTY => \&validate_number, P_DLRUOM => \&validate_p_dlruom ); validate_fields(EACH, P_DLRUOM); sub validate_fields { my ($updateval, $colname) = @_; #print "$updateval $colname\n"; if (! exists $validator{ $colname }) { print "'$colname' is not a valid column name."; }; my $code = $validator{ $colname }; if (! $code->($updateval, $colname)) { print "'$updateval' is not a valid value for '$colname'."; } else { print "'$updateval' is a valid value for '$colname'."; return 1 }; } sub validate_p_dlruom { my $val = shift; my @match = grep (/$val/i, @p_dlruom); print "The value of $val you have chosen for P_DLRUOM is outside of t +he allowable range.\n" if !(@match); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Need help with Validation script
by agianni (Hermit) on Jul 16, 2007 at 19:47 UTC | |
by ssmith001 (Initiate) on Jul 16, 2007 at 20:13 UTC |