?????? ?????
????????§Ø?
?????????
1??while???
2??until???
3??for???
4??????§Ò?(????)???????foreach???
5??do???
6?????????
7???????goto???
????????????
????????§Ø?
if ( <expression>) {
<statement_block_1>
}
elsif (
<expression> ) {
<statement_block_2>
}
...
else{
<statement_block_3>
}
?????????
1??while???
while (
<expression> ) {
<statement_block>
}
2??until???
until (
<expression> ) {
<statement_block>
}
3????C??for???
????
for ($count=1; $count
<= 5; $count++) {
# statements
inside the loop go here
}
????????for???????????????????????
for ($line =
<STDIN>, $count = 1; $count <= 3;
$line = <STDIN>, $count++) {
print
($line);
}
??????????????
$line = <STDIN>;
$count = 1;
while ($count <= 3) {
print
($line);
$line =
<STDIN>;
$count++;
}
4??????§Ò?(????)????????????foreach??
?????
foreach localvar
(listexpr) {
statement_block;
}
????
foreach $word (@words) {
if ($word eq
"the") {
print
("found the word 'the'\n");
}
}
???
(1)????????????localvar?????????????????????????????????????????????
(2)??????§Ú????????????????????????????»Ç
@list = (1, 2, 3, 4, 5);
foreach $temp (@list) {
if ($temp ==
2) {
$temp
= 20;
}
}
???@list??????(1, 20, 3, 4, 5)??
5??do???
do {
statement_block
} while_or_until
(condexpr);
do??????????????????
6?????????
???????last????C?§Ö?break?????????????????????next????C?§Ö?continue?????????PERL???§Ö??????????redo???¾©?????????????????????????????????????????????redo??????do????§Ó??????¨¢?
7???????goto label;???
????????????
???statement
keyword condexpr??????keyword???if??unless??while??until???Ȃ
print
("This is zero.\n") if ($var == 0);
print
("This is zero.\n") unless ($var != 0);
print
("Not zero yet.\n") while ($var-- > 0);
print
("Not zero yet.\n") until ($var-- == 0);
????????§Ø?§Õ????—¨?????????§Ö??
????? ????? ??
paper | appdir | ssv
97av