Solved

perl error

Posted on 2000-05-09
4
129 Views
Last Modified: 2010-03-05
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 ??
0
Comment
Question by:Dewaana
  • 3
4 Comments
 
LVL 8

Accepted Solution

by:
shlomoy earned 100 total points
ID: 2791987
If your fields data is in an array called @fields then you can do:

foreach $field (@fields) {
      error_message() if (!defined($field));
}
0
 
LVL 8

Expert Comment

by:shlomoy
ID: 2791997
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
 

Author Comment

by:Dewaana
ID: 2792095
thank u very much
0
 
LVL 8

Expert Comment

by:shlomoy
ID: 2792281
Sure.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now