InterviewSolution
Saved Bookmarks
| 1. |
How will you create an infinite loop using Perl's for loop? Also, tell me how to terminate such loops? |
|
Answer» The syntax of the for loop in Perl is for(initialization; CONDITIONAL expression; increment or DECREMENT) { // code body that needs to be executed repetedly }But imagine a SITUATION where you have put double semicolon (;;) within the for loop. It means there is no beginning value or TERMINATING condition and hence it will execute for infinite times. To stop executing such infinitely running LOOPS, you can programmers can use the Ctrl + C shortcut. |
|