Perl-redo-statement
提供:Dev Guides
Perl REDOステートメント
*redo* コマンドは、条件を再度評価せずにループブロックを再起動します。 LABELがループのラベルである場合、LABELに *redo* ステートメントを指定できます。 *redo* ステートメントは、LABELが指定されていない場合に最も近いループに適用されるネストされたループ内で使用できます。
ループに continue ブロックがある場合、条件を評価する前に実行されません。
構文
*redo* ステートメントの構文は次のとおりです-
redo [LABEL]
流れ図
例
次のプログラムは、 redo ステートメントの使用方法を示しています-
#/usr/local/bin/perl
$a = 0;
while($a < 10) {
if( $a == 5 ) {
$a = $a + 1;
redo;
}
print "Value of a = $a\n";
} continue {
$a = $a + 1;
}
これは、次の結果を生成します-
Value of a = 0
Value of a = 1
Value of a = 2
Value of a = 3
Value of a = 4
Value of a = 6
Value of a = 7
Value of a = 8
Value of a = 9