#!/usr/bin/perl # ... code deleted here ... if (@errors = &areErrors) { &printErrors; } else { &finishAndExit; } # Check that the value of the *required* CGI parameter # "price" is indeed numeric. If not, push a message # onto the @ERRORS array. sub areErrors { my @ERRORS; if (!$query->param('price') && ($query->param('price') !~ /^0+$/)) { # The call to param() for the 'price' evaluated to # false, and it also wasn't just a string of zeroes. push @ERRORS, "'price' is a required numeric value."; if ($query->param('price') !~ /^\d+$/) { # There were characters other than digits here. push @ERRORS, "'price' must be a numeric value."; } return @ERRORS; } # Output an HTML unordered list, with each list item # being an error from the @ERRORS array. sub printErrors { my @ERRORS = @_; my $error; print "

Errors in your input:

\n"; print "\n"; }