The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

<html>
<head>
<title>Test for Embperl - Loop Metacommand</title>
</head>

<body>

[- $i = 0 -]
[$ while($i &lt;= 2)$]
    [+ $i++ +]
[$ endwhile $]

[- $i = 0 -]
[$ while $i &lt;= $#ffld $]
    [+ $ffld[$i] +] = [+ $fdat{$ffld[$i]} +]
    [- $j = 0 -]
    [$ while $j &lt;= $i $]
        [+ $j++ +] 
    [$ endwhile $]
    <BR>
    [- $i++ -]
[$ endwhile $]


[- %h = ('A' => 1, 'B' => 2, 'C' => 3) ; -]
[- @a = ('a', 'b', 'c', 'd') ; -]

[- @hh = map { $_ => $h{$_} } sort keys %h  -]  
[$ while ($v = shift @hh, $k = shift @hh) $]
    [+ "$v = $k" +]<br>
[$ endwhile $]

[- $i = 0 -]
[$ while $i <= $#a $]
    [+ "\@a[$i] = $a[$i]" +]<br>
	[- $i++ -]
[$ endwhile $]

[- $i = 0 -]
[$ do $]
    [+ "\@a[$i] = $a[$i]" +]<br>
	[- $i++ -]
[$ until $i > $#a $]

[$ foreach $v (@a) $]
	[+ $v +] <br>
[$ endforeach $]

[$ foreach $v (1, 3, 5, 7, 9) $]
	[+ $v +] <br>
[$ endforeach $]

[$ foreach $v (1..10) $]
	[+ $v +] <br>
[$ endforeach $]

[$ foreach $v(1..5) $]
	2:[+ $v +] <br>
[$ endforeach $]

[- $i = 0 -]
[$ do $]
    [+ "\@a[$i] = $a[$i]" +]<br>
	[- @hh = map { $_ => $h{$_} } sort keys %h  -]  
	[$ while ($v = shift @hh, $k = shift @hh) $]
		[+ "$v = $k" +]<br>
		[$ foreach $fv (1, 3, 5, 7, 9) $]
			[+ $fv +] <br>
		[$ endforeach $]
		[$ foreach $fv (()) $]
			[+ $fv +] <br>
			[- @hhh = map { $_ => $h{$_} } sort keys %h  -]  
			[$ while ($wv = shift @hhh, $wk = shift @hhh) $]
				[+ "$wv = $wk" +]<br>
			[$ endwhile $]
		[$ endforeach $]
	[$ endwhile $]
	[- $i++ -]
[$ until $i > $#a $]


[- undef @a ; undef @b -]

[$ if 1 $]

x

 [$ foreach $a (@a) $]
   [$ foreach $b (@b) $]
   [$ endforeach $]
 [$ endforeach $]

y

[$ endif $]


[- @bar = ('a', 'b', 'c'); -]
[$ foreach $foo (@bar) $]
  [* next if ($foo eq 'c'); *]
  [+ $foo +]
[$ endforeach $]

[$ foreach $foo (@bar) $]
  [* next if ($foo eq 'c'); *]
  x = [+ $foo +] = z
[$ endforeach $]

[$ foreach $foo (@bar) $]
  [$if ($foo eq 'c') $][$ last $][$endif$]
  last = [+ $foo +] = z
[$ endforeach $]

[$ foreach $foo (@bar) $]
  [$if ($foo eq 'b') $][$ next $][$endif$]
  next = [+ $foo +] = z
[$ endforeach $]

</body>
</html>