| 1 |
|
| 2 |
<html> |
| 3 |
<head> |
| 4 |
<title>Embperl Examples - Loop Metacommands</title> |
| 5 |
</head> |
| 6 |
<body background="../images/jazzbkgd.gif"> |
| 7 |
|
| 8 |
<h1>Embperl Examples - Loop Metacommands</h1> |
| 9 |
<hr><h3>This is a example of using the while metacommand in embperl to show the environment</h3> |
| 10 |
|
| 11 |
[$ while ($k, $v) = each (%ENV) $] |
| 12 |
[+ $k +] = [+ $v +] <BR> |
| 13 |
[$ endwhile $] |
| 14 |
|
| 15 |
<hr><h3>This is a example of using the while metacommand to show the loaded |
| 16 |
modules, with using an index</h3> |
| 17 |
|
| 18 |
[- $i = 0; @k = keys %INC -] |
| 19 |
[$ while ($i < $#k) $] |
| 20 |
[+ $k[$i] +] = [+ $INC{$k[$i]} +]<BR> |
| 21 |
[- $i++ -] |
| 22 |
[$ endwhile $] |
| 23 |
|
| 24 |
<hr><h3>This is a example of using the do .. until metacommand to show the array @arr = (3,5,7)</h3> |
| 25 |
|
| 26 |
[- @arr = (3, 5, 7); $i = 0 -] |
| 27 |
[$ do $] |
| 28 |
[+ $arr[ $i++ ] +] |
| 29 |
[$ until $i > $#arr $] |
| 30 |
|
| 31 |
|
| 32 |
<hr><h3>This is a example of using the foreach metacommand to show the list (1..10)</h3> |
| 33 |
|
| 34 |
[$ foreach $v (1..10) $] |
| 35 |
[+ $v +] |
| 36 |
[$ endforeach $] |
| 37 |
|
| 38 |
[$ if $ENV{MOD_PERL} $] |
| 39 |
<hr><h3>This is a example of using the while metacommand in embperl to show the http headers send from the browser</h3> |
| 40 |
|
| 41 |
[- %hdr = $req_rec -> headers_in ; -] |
| 42 |
[$ while ($k, $v) = each (%hdr) $] |
| 43 |
[+ $k +] = [+ $v +] <BR> |
| 44 |
[$ endwhile $] |
| 45 |
[$endif$] |
| 46 |
|
| 47 |
<p><hr> |
| 48 |
|
| 49 |
<small>HTML::Embperl (c) 1997-1998 G.Richter</small> |
| 50 |
|
| 51 |
</body> |
| 52 |
</html> |