in reply to Simple Hash Q.

Well, I might be wrong on this but I though up something like this...

$message = ""; $errmsg = "<p>Field 'first' must be filled in.</p>\n" ; if ($FirstName eq "") { $message = $errmsg ; $err = 1 ; } $errmsg = "<p>Field 'last' must be filled in.</p>\n" ; if ($LastName eq "") { $message = $errmsg ; $err = 1 ; } $errmsg = "<p>Please enter a valid email address</p>\n" ; if ($Email !~ /.+\@.+\..+/) { # i had alot of trouble with this. $message = $errmsg ; $err = 1 ; } if ($err) { &error; } sub error{ print $errmsg; }


Wanna be perl hacker.
Dave AKA damian

Replies are listed 'Best First'.
Re: Re: Simple Hash Q.
by Fastolfe (Vicar) on Nov 27, 2000 at 04:05 UTC
    When I do things like that, I tend to put the errors in an array instead. Makes things more readable:
    foreach (@required) { push(@errors, "$_ is a required field") unless $q->param($_); } push(@errors, "E-mail address is invalid") unless Valid($q->param('ema +il')); push(@errors, "The moon is full") if $moon->isFull; if (@errors) { &Error(@errors); } else { &Success("You rule."); }