| 1 |
|
| 2 |
<html> |
| 3 |
<head> |
| 4 |
<title>Some Plain tests Embperl</title> |
| 5 |
</head> |
| 6 |
|
| 7 |
<body> |
| 8 |
|
| 9 |
[$ var $a $b $c $d $e $i $j $ii $v $k $fv @a %a @b %h @c @ii %hash $wv $wk @hh @hhh $] |
| 10 |
|
| 11 |
Here it starts with some HTML Text<P> |
| 12 |
|
| 13 |
All values should be undefined: |
| 14 |
|
| 15 |
$a = [+ $a || '' +] <BR> |
| 16 |
$b = [+ $b || '' +] <BR> |
| 17 |
$c = [+ $c || '' +] <BR> |
| 18 |
$d = [+ $d || '' +] <BR> |
| 19 |
$e = [+ $e || '' +] <BR> |
| 20 |
|
| 21 |
|
| 22 |
First of all assign a value: |
| 23 |
[- $a = '(this is the value in $a)' -] <BR> |
| 24 |
|
| 25 |
Now we have some 'Umlaute': |
| 26 |
|
| 27 |
|
| 28 |
[- $b = "$a äöü" -] |
| 29 |
|
| 30 |
Now lets look what we are getting from this:<BR> |
| 31 |
[+ $a +] [+ $b +]<BR> |
| 32 |
|
| 33 |
And now a and b together: [+ "$a$b" +]<P> |
| 34 |
|
| 35 |
Here we have some HTML tags within the perl code, Embperl will delete them!<BR> |
| 36 |
|
| 37 |
[+ $c = <BR> 6 + 17 <font size="3"> * 3 +] |
| 38 |
|
| 39 |
Embperl will also translate HMTL escapes to the right characters i.e. $a &lt; 6 will get the perl expression $a < 6: <BR> |
| 40 |
|
| 41 |
[- $e = 2 -] |
| 42 |
[+ $d = $e < 6 +] |
| 43 |
|
| 44 |
Now they should have a value |
| 45 |
|
| 46 |
$a = [+ $a +] <BR> |
| 47 |
$b = [+ $b +] <BR> |
| 48 |
$c = [+ $c +] <BR> |
| 49 |
$d = [+ $d +] <BR> |
| 50 |
$e = [+ $e +] <BR> |
| 51 |
|
| 52 |
[- $a = 1; $b = 0; $c = 5; $d = 'txt' -] |
| 53 |
|
| 54 |
|
| 55 |
[$if $a$] |
| 56 |
a <br> |
| 57 |
[$ endif$] |
| 58 |
|
| 59 |
|
| 60 |
[$if $a $] |
| 61 |
a <br> |
| 62 |
[$else$] |
| 63 |
not a<br> |
| 64 |
[$ endif $] |
| 65 |
|
| 66 |
|
| 67 |
[$ if $a$] |
| 68 |
a <br> |
| 69 |
[$if $b == 0$] |
| 70 |
b is null <br> |
| 71 |
[$else$] |
| 72 |
b is not null <br> |
| 73 |
[$endif$] |
| 74 |
[$ else$] |
| 75 |
not a<br> |
| 76 |
[$ endif $] |
| 77 |
|
| 78 |
|
| 79 |
[$ if $a$] |
| 80 |
a <br> |
| 81 |
[$if $b == 0$] |
| 82 |
b is null <br> |
| 83 |
[$else$] |
| 84 |
b is not null <br> |
| 85 |
[$endif$] |
| 86 |
[$ else$] |
| 87 |
not a<br> |
| 88 |
[$if $b == 0$] |
| 89 |
b is null <br> |
| 90 |
[$else$] |
| 91 |
b is not null <br> |
| 92 |
[$endif$] |
| 93 |
[$ endif $] |
| 94 |
|
| 95 |
|
| 96 |
[$ if !$a$] |
| 97 |
not a <br> |
| 98 |
[$if $b == 0$] |
| 99 |
b is null <br> |
| 100 |
[$else$] |
| 101 |
b is not null <br> |
| 102 |
[$endif$] |
| 103 |
[$ else$] |
| 104 |
a<br> |
| 105 |
[$if $b == 0$] |
| 106 |
b is null <br> |
| 107 |
[$else$] |
| 108 |
b is not null <br> |
| 109 |
[$endif$] |
| 110 |
[$ endif $] |
| 111 |
|
| 112 |
|
| 113 |
[- $i = 0 -] |
| 114 |
[$ while $i <= $#ffld $] |
| 115 |
[+ $ffld[$i] +] = [+ $fdat{$ffld[$i]} +] |
| 116 |
[- $j = 0 -] |
| 117 |
[$ while $j <= $i $] |
| 118 |
[+ $j++ +] |
| 119 |
[$ endwhile $] |
| 120 |
<BR> |
| 121 |
[- $i++ -] |
| 122 |
[$ endwhile $] |
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
<table> |
| 127 |
<tr> |
| 128 |
<td>[+ $c[$row][$col] +] </td> |
| 129 |
</tr> |
| 130 |
</table> |
| 131 |
|
| 132 |
|
| 133 |
<p> $tabmode = default <p> |
| 134 |
|
| 135 |
<hr><p>Display an two dimensional array with one, two and three columns !<BR> |
| 136 |
Please take a look at the source in your browser to see the difference<BR> |
| 137 |
|
| 138 |
[- |
| 139 |
undef @a ; |
| 140 |
undef @b ; |
| 141 |
|
| 142 |
$a[0][0] = 'a1/1' ; |
| 143 |
$a[1][0] = 'a2/1' ; |
| 144 |
$a[1][1] = 'a2/2' ; |
| 145 |
$a[2][0] = 'a3/1' ; |
| 146 |
$a[2][1] = 'a3/2' ; |
| 147 |
$a[2][2] = 'a3/3' ; |
| 148 |
|
| 149 |
$b[0][0] = 'b1/1' ; |
| 150 |
$b[1][0] = 'b2/1' ; |
| 151 |
$b[1][1] = 'b2/2' ; |
| 152 |
$b[2][0] = 'b3/1' ; |
| 153 |
$b[2][1] = 'b3/2' ; |
| 154 |
$b[2][2] = 'b3/3' ; |
| 155 |
|
| 156 |
$maxcol=99 ; |
| 157 |
-] |
| 158 |
$a[0][[0] = '1/1' ;<BR> |
| 159 |
$a[1][[0] = '2/1' ;<BR> |
| 160 |
$a[1][[1] = '2/2' ;<BR> |
| 161 |
$a[2][[0] = '3/1' ;<BR> |
| 162 |
$a[2][[1] = '3/2' ;<BR> |
| 163 |
$a[2][[2] = '3/3' ;<BR> |
| 164 |
|
| 165 |
<P>$tabmode = default <P> |
| 166 |
|
| 167 |
<table border="1" width="100%"> |
| 168 |
<tr> |
| 169 |
<td>[+ $a[$row][$col] +] </td> |
| 170 |
</tr> |
| 171 |
</table> |
| 172 |
|
| 173 |
<table border="2" width="100%"> |
| 174 |
<tr> |
| 175 |
<td>[+ $a[$row][$col] +] </td> |
| 176 |
</tr> |
| 177 |
</table> |
| 178 |
|
| 179 |
<table border="3" width="100%"> |
| 180 |
<tr> |
| 181 |
<td>[+ $a[$row][$col] +] </td> |
| 182 |
</tr> |
| 183 |
</table> |
| 184 |
|
| 185 |
<table border="4" > |
| 186 |
<tr> |
| 187 |
<td> |
| 188 |
<table border="5" > |
| 189 |
<tr> |
| 190 |
<td>[+ $b[$row][$col] +] </td> |
| 191 |
</tr> |
| 192 |
</table> |
| 193 |
|
| 194 |
[+ $a[$row][$col] +] </td> |
| 195 |
</tr> |
| 196 |
</table> |
| 197 |
|
| 198 |
<P>[+ $Embperl::VERSION +]<P> |
| 199 |
|
| 200 |
<P>[+ $tabmode || 17 +]<P> |
| 201 |
<P>[+ local $tabmode = 1 +]<P> |
| 202 |
|
| 203 |
<P> |
| 204 |
|
| •205 |
[- $i = 0 ; while ($i < 10) { $ii[$i] = "ii[$i] = $i" ; $i++ ; } -] |
| 206 |
|
| 207 |
|
| 208 |
[- $i = 0 -] |
| 209 |
[$ while $i <= $#ffld $] |
| 210 |
[+ $ffld[$i] +] = [+ $fdat{$ffld[$i]} +] |
| 211 |
[- $j = 0 -] |
| 212 |
[$ while $j <= $i $] |
| 213 |
[+ $j++ +] |
| 214 |
[$ endwhile $] |
| 215 |
<BR> |
| 216 |
[- $i++ -] |
| 217 |
[$ endwhile $] |
| 218 |
|
| 219 |
[- $i = 0 -] |
| 220 |
[$ while($i <= 2)$] |
| 221 |
[+ $i++ +] |
| 222 |
[$ endwhile $] |
| 223 |
|
| 224 |
|
| 225 |
[- %h = ('A' => 1, 'B' => 2, 'C' => 3) ; -] |
| 226 |
[- @a = ('a', 'b', 'c', 'd') ; -] |
| 227 |
|
| 228 |
[- @hh = map { $_ => $h{$_} } sort keys %h -] |
| 229 |
[$ while ($v = shift @hh, $k = shift @hh) $] |
| 230 |
[+ "$v = $k" +]<br> |
| 231 |
[$ endwhile $] |
| 232 |
|
| 233 |
[- $i = 0 -] |
| 234 |
[$ while $i <= $#a $] |
| 235 |
[+ "\@a[$i] = $a[$i]" +]<br> |
| 236 |
[- $i++ -] |
| 237 |
[$ endwhile $] |
| 238 |
|
| 239 |
[- $i = 0 -] |
| 240 |
[$ do $] |
| 241 |
[+ "\@a[$i] = $a[$i]" +]<br> |
| 242 |
[- $i++ -] |
| 243 |
[$ until $i > $#a $] |
| 244 |
|
| 245 |
[$ foreach $v (@a) $] |
| 246 |
[+ $v +] <br> |
| 247 |
[$ endforeach $] |
| 248 |
|
| 249 |
[$ foreach $v (1, 3, 5, 7, 9) $] |
| 250 |
[+ $v +] <br> |
| 251 |
[$ endforeach $] |
| 252 |
|
| 253 |
[$ foreach $v (1..10) $] |
| 254 |
[+ $v +] <br> |
| 255 |
[$ endforeach $] |
| 256 |
|
| 257 |
[$ foreach $v(1..5) $] |
| 258 |
2:[+ $v +] <br> |
| 259 |
[$ endforeach $] |
| 260 |
|
| 261 |
[- %hash = ( a=>1, b=>2, c=>3) -] |
| 262 |
[$ foreach $v(sort keys %hash) $] |
| 263 |
3:[+ $v +] <br> |
| 264 |
[$ endforeach $] |
| 265 |
|
| 266 |
[- $i = 0 -] |
| 267 |
[$ do $] |
| 268 |
[+ "\@a[$i] = $a[$i]" +]<br> |
| 269 |
[- @hh = map { $_ => $h{$_} } sort keys %h -] |
| 270 |
[$ while ($v = shift @hh, $k = shift @hh) $] |
| 271 |
[+ "$v = $k" +]<br> |
| 272 |
[$ foreach $fv (1, 3, 5, 7, 9) $] |
| 273 |
[+ $fv +] <br> |
| 274 |
[$ endforeach $] |
| 275 |
[$ foreach $fv (()) $] |
| 276 |
[+ $fv +] <br> |
| 277 |
[- @hh = map { $_ => $h{$_} } sort keys %h -] |
| 278 |
[$ while ($wv = shift @hh, $wk = shift @hh) $] |
| 279 |
[+ "$wv = $wk" +]<br> |
| 280 |
[$ endwhile $] |
| 281 |
[$ endforeach $] |
| 282 |
[$ endwhile $] |
| 283 |
[- $i++ -] |
| 284 |
[$ until $i > $#a $] |
| 285 |
|
| 286 |
|
| 287 |
[- undef @a ; undef @b -] |
| 288 |
|
| 289 |
[$ if 1 $] |
| 290 |
|
| 291 |
x |
| 292 |
|
| 293 |
[$ foreach $a (@a) $] |
| 294 |
[$ foreach $b (@b) $] |
| 295 |
[$ endforeach $] |
| 296 |
[$ endforeach $] |
| 297 |
|
| 298 |
y |
| 299 |
|
| 300 |
[$ endif $] |
| 301 |
|
| 302 |
|
| 303 |
<table> |
| 304 |
<tr> |
| 305 |
<td>[+ $ii[$row] +] </td> |
| 306 |
</tr> |
| 307 |
</table> |
| 308 |
|
| 309 |
</body> |
| 310 |
</html> |