Perl redo Function



Description

This function restarts the current loop without forcing the control statement to be evaluated. No further statements in the block are executed. A continue block, if present, will not be executed. If LABEL is specified, execution restarts at the start of the loop identified by LABEL.

Syntax

Following is the simple syntax for this function −

redo LABEL

redo

Return Value

This function does not return any value.

Example

Following is the example code showing its basic usage −

#!/usr/bin/perl -w

$c = 1;
$d = 4;
LABEL: {
   $c++;
   $e = 5;
   redo LABEL if ($c < 3);
   $f = 6;
   last LABEL if ($e > 3);
   $g = 7;
}
$h = 8;
print ("$c $d $e $f $g $h\n");

When above code is executed, it produces the following result −

3 4 5 6  8  
perl_function_references.htm
Advertisements