1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
|
<html>
<head>
<title>IF Metacommand in Embperl</title>
</head>
<body>
[- $a = 1; $b = 0; $c = 5; $d = 'txt' -]
a1
[* if ($a) { *]
a <br>
[* } *]
a2
[* if ( $a) { *]
a <br>
[* } else { *]
not a<br>
[* } *]
a3
[* if ( $a<br>) { *]
a <br>
[* } else { <br>*]
not a<br>
[* } <br>*]
a4
[*<br>if ($a) { *]
a <br>
[* <br> } else { <br>*]
not a<br>
[* <br>} *]
a5
[* if ($a) {*]
a <br>
[* if ( $b == 0) {*]
b is null <br>
[* } else { *]
b is not null <br>
[* } *]
[* } else{*]
not a<br>
[* } *]
[* if ($a) {*]
a <br>
[* if ( $b == 0) {*]
b is null <br>
[* } else { *]
b is not null <br>
[* } *]
[* } else {*]
not a<br>
[* if ( $b == 0) {*]
b is null <br>
[* } else { *]
b is not null <br>
[* } *]
[* } *]
[* if (!$a) {*]
not a <br>
[* if ( $b == 0) {*]
b is null <br>
[* } else { *]
b is not null <br>
[* } *]
[* } else {*]
a<br>
[* if ( $b == 0) {*]
b is null <br>
[* } else { *]
b is not null <br>
[* } *]
[* } *]
[* if ($a) {*]
a <br>
[* if ( $b == 0) {*]
b is null <br>
[* } elsif ($c == 5) { *]
b is not null and c is 5 <br>
[* } elsif ($d eq 'txt') {*]
b is not null and c is not 5, but d is 'txt' <br>
[* } else { *]
b is not null and c is not 5 and d is not 'txt' <br>
[* } *]
[* } else {*]
not a<br>
[* } *]
[- $ttrue = 'true'; $tfalse = '' -]
[* if ( $ttrue) { *]
ttrue = true
[* } else { *]
ttrue = false
[* } *]
[* if ( $tfalse) { *]
tfalse = true
[* } else { *]
tfalse = false
[* } *]
</body>
</html>
|