On Thu, May 11, 2000 at 12:23:40PM +0200, Jimmy Lantz wrote: > 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än > info:</b><PRE>$in{"${nummer}General"}</PRE>!; > } > print HTML_FIL qq!<p><b>Lä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"}!; > } > Well, you need some way to group the keys and the HTML together. You could do this with a hash, but then you'd need to add a way to get the right order. Here's some code that just uses an array: @fields = ( "General", qq!<p><b>Allmän info:</b><PRE>$in{"${nummer}General"}</PRE>!, "Larare", qq!<p><b>Lärare:</b><br>$in{"${nummer}Larare"}!, "Larare-email", qq!<a href="mailto:$in{"${nummer}Larare-email"}">Email</a></p>!, "Larare2", qq!$in{"${nummer}Larare2"}!, ); for ($i = 0; $i <= $#fields; $i += 2) { if ($in{"$nummer$fields[$i]} ne '') { print HTML_FIL $fields[$i+1]; } } Ronald ==== Want to unsubscribe from this list? ==== Send mail with body "unsubscribe" to macperl-forum-request@macperl.org