Switch layouts home | FAQ | | P1 | P2 | P3 | P4 | P5 |  | A1 | A2 | A3  | | B1

Loops and Conditions

1. Create a copy or a link to PB. It may be either a hard link or a symbolic link depending on your preferences and settings of the web server. The name of the link can be anything as long as the web server is going to run it as a cgi script. For example, p4.cgi
ln ../cgi-bin/pb.pl ./p4.cgi    or
ln -sf ../cgi-bin/pb.pl ./p4.cgi

2. Create a project configuration file. The name should be cgi-script's name + ".pm". For p4.cgi this file should be ./p4.cgi.pm
$templatesdir="sampledir";
$Parameter{Page}="home"; 
$Template{home}="$templatesdir/p4-home.html";
1;

3. Create an html-template file, p4-home.html
1. for-loop
<br>
<TABLE>
<!%for($x=1,$i=1;$i<=3;$i++)%>
<TR>
<!%for($j=1;$j<=3;$j++)%>
<TD NOWRAP>
<!%for($k=1;$k<=2;$k++)%>
<!%for($l=1;$l<=2;$l++)%>
<!%if !($x%4)%><b><!%show $x++%></b>
<!%else%><!%show $x++%>
<!%endif%>
<!%endfor%>
<br>
<!%endfor%>
</TD>
<!%endfor%>
</TR>
<!%endfor%>
</TABLE>
<br>
1. while-loop
<br>
<!%set @a=(1,2,3,4,5,6,7,8,9,10)%>
<!%while($x=shift(@a))%>
<!%if !($x%2)%><b><!%show $x++%></b>
<!%else%><!%show $x++%>
<!%endwhile%>

4. This web project is complete. Check it out:
/PB/p4.cgi


2002-03