perl error

I am geting information from user
and want to print an error message if any of the fields were empty. But i don't wanna go thorought each entry one bye one with a different if statement for each of them. Is there any way to do this all in one or some easier way of doing it rather than checking each entry ??
DewaanaAsked:
Who is Participating?
 
shlomoyConnect With a Mentor Commented:
If your fields data is in an array called @fields then you can do:

foreach $field (@fields) {
      error_message() if (!defined($field));
}
0
 
shlomoyCommented:
use CGI;
@names = $query->param
foreach $name (@names) {
      error_message() if (!defined($name));
}


where error_message() is a subroutine which handles the error message you'd like to output to the user.
0
 
DewaanaAuthor Commented:
thank u very much
0
 
shlomoyCommented:
Sure.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.