[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl-WebCGI] Re: [MacPerl-Forum] A lot of IF's = Unsmart ? (Newbie Question)



On Wed, May 10, 2000 at 11:21:39AM +0200, Jimmy Lantz wrote:
> Hi I have a lot of
> stings in the following format in my script :
> 
> if ($in{"${nummer}Klitt"} ne '')
> {
> print HTML_FILE qq!<p>KLitt:<PRE>$in{"${nummer}Klitt"}</PRE>!;
> }
> Is there a smarter way to this ? I have like 20 of the Checking if a
> field is left empty Do Error messg.
> and in the above: if it's not Print the line to A File.

You might do this:

foreach $key ("${nummer}Klitt", ...) {
  if ($in{$key} ne '') {
    print HTML_FILE qq!<p>Klitt:<PRE>$in{$key}</PRE>!;
  }
}

Now you've got all your keys listed in the foreach loop, and just one if
statement.

Ronald

==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-webcgi-request@macperl.org