[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)



Hi, I thank you for your reply but I think I must have been unclear in my
question.
I have some variables changing Like
Klitt is not allwas the same and then it shouldnt print the same either.
The below is a bigger exerpt form my script:
Is there as yyou can see a smarte way to test the IF's in like a foreach
....
Yrs sincerely
Jimmy lantz


sub do_delkurs
{
my($nummer) = @_ ;


if ($in{"${nummer}General"} ne '') {
print HTML_FIL qq!<p><b>Allm&auml;n
info:</b><PRE>$in{"${nummer}General"}</PRE>!;
}
print HTML_FIL qq!<p><b>L&auml;rare:</b><br>$in{"${nummer}Larare"}!;

if ($in{"${nummer}Larare-email"} ne '') {
print HTML_FIL qq!<a
href="mailto:$in{"${nummer}Larare-email"}">Email</a></p>!;
}

if ($in{"${nummer}Larare2"} ne '') {
print HTML_FIL qq!$in{"${nummer}Larare2"}!;
}


Ronald J Kimball wrote:

> 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