Debian Codegraph @

test/html/loop.htm

raw
1
2 <html>
3 <head>
4 <title>Test for Embperl - Loop Metacommand</title>
5 </head>
6
7 <body>
8
9 [- $i = 0 -]
10 [$ while($i &lt;= 2)$]
11 [+ $i++ +]
12 [$ endwhile $]
13
14 [- $i = 0 -]
15 [$ while $i &lt;= $#ffld $]
16 [+ $ffld[$i] +] = [+ $fdat{$ffld[$i]} +]
17 [- $j = 0 -]
18 [$ while $j &lt;= $i $]
19 [+ $j++ +]
20 [$ endwhile $]
21 <BR>
22 [- $i++ -]
23 [$ endwhile $]
24
25
26 [- %h = ('A' => 1, 'B' => 2, 'C' => 3) ; -]
27 [- @a = ('a', 'b', 'c', 'd') ; -]
28
29 [- @hh = map { $_ => $h{$_} } sort keys %h -]
30 [$ while ($v = shift @hh, $k = shift @hh) $]
31 [+ "$v = $k" +]<br>
32 [$ endwhile $]
33
34 [- $i = 0 -]
35 [$ while $i <= $#a $]
36 [+ "\@a[$i] = $a[$i]" +]<br>
37 [- $i++ -]
38 [$ endwhile $]
39
40 [- $i = 0 -]
41 [$ do $]
42 [+ "\@a[$i] = $a[$i]" +]<br>
43 [- $i++ -]
44 [$ until $i > $#a $]
45
46 [$ foreach $v (@a) $]
47 [+ $v +] <br>
48 [$ endforeach $]
49
50 [$ foreach $v (1, 3, 5, 7, 9) $]
51 [+ $v +] <br>
52 [$ endforeach $]
53
54 [$ foreach $v (1..10) $]
55 [+ $v +] <br>
56 [$ endforeach $]
57
58 [$ foreach $v(1..5) $]
59 2:[+ $v +] <br>
60 [$ endforeach $]
61
62 [- $i = 0 -]
63 [$ do $]
64 [+ "\@a[$i] = $a[$i]" +]<br>
65 [- @hh = map { $_ => $h{$_} } sort keys %h -]
66 [$ while ($v = shift @hh, $k = shift @hh) $]
67 [+ "$v = $k" +]<br>
68 [$ foreach $fv (1, 3, 5, 7, 9) $]
69 [+ $fv +] <br>
70 [$ endforeach $]
71 [$ foreach $fv (()) $]
72 [+ $fv +] <br>
73 [- @hhh = map { $_ => $h{$_} } sort keys %h -]
74 [$ while ($wv = shift @hhh, $wk = shift @hhh) $]
75 [+ "$wv = $wk" +]<br>
76 [$ endwhile $]
77 [$ endforeach $]
78 [$ endwhile $]
79 [- $i++ -]
80 [$ until $i > $#a $]
81
82
83 [- undef @a ; undef @b -]
84
85 [$ if 1 $]
86
87 x
88
89 [$ foreach $a (@a) $]
90 [$ foreach $b (@b) $]
91 [$ endforeach $]
92 [$ endforeach $]
93
94 y
95
96 [$ endif $]
97
98
99 [- @bar = ('a', 'b', 'c'); -]
100 [$ foreach $foo (@bar) $]
101 [* next if ($foo eq 'c'); *]
102 [+ $foo +]
103 [$ endforeach $]
104
105 [$ foreach $foo (@bar) $]
106 [* next if ($foo eq 'c'); *]
107 x = [+ $foo +] = z
108 [$ endforeach $]
109
110 [$ foreach $foo (@bar) $]
111 [$if ($foo eq 'c') $][$ last $][$endif$]
112 last = [+ $foo +] = z
113 [$ endforeach $]
114
115 [$ foreach $foo (@bar) $]
116 [$if ($foo eq 'b') $][$ next $][$endif$]
117 next = [+ $foo +] = z
118 [$ endforeach $]
119
120 </body>
121 </html>