Saved Bookmarks
| 1. |
Define the goto statement in Perl? |
|
Answer» Perl's GOTO statement is a jumping statement, that MAKES a jump from one PART of the program to the other when the program encounters the goto label. It is sometimes referred to as the unconditional jump statement because the jumping from one section of the program to the other takes place without any condition. Programmers can use the goto statement anywhere WITHIN a function. The syntax is: LABEL_NAME: Statement 1; Statement 2; . . . . . Statement n; goto LABEL_NAME; Program: sub dispNumb() { my $numb = 1; lab: print "$numb "; $numb++; if ($numb <= 20) { goto lab; } } # Driver CODE dispNumb(); |
|