Wednesday, 1 January 2020

What is a continue function in Perl?


Control statement makes iteration to beginning of loops for next iteration.

Method 1:

$t = 0;

while($t < 3) {
   print "Value of var t = $t\n";
} continue {
   $t = $t + 1;
}



Method 2:

@array = (4,5,1,9,2);

foreach $t (@array) {
   print "Value of t = $t\n";
} continue {
   last if $t == 9;
}

Method 3:

@array = (4,5,1,9,2);

for(@array)
{
     print "$_\n";
}
continue {
   last if $_ == 2;
}

kaavannan perl blogspot

Labels: , , ,

0 Comments:

Post a Comment

Note: only a member of this blog may post a comment.

<< Home