such as "Introduction", "Conclusion"..etc
of this program is to show the use of loops like while, until, for, foreach in the Perl language. Loops are used if
we need to perform a certain action for a number of times.
present exercise, for the “until”
condition, we assign a value (“venkat”) to a scalar variable $r. We then ask
the user to enter a value. This value will be assigned to $i. The <STDIN>
command is to tell the program that the user needs to give the value during the
execution. Its abbreviation is Standard Input. When a program comes across the
command, it stops and waits for the user to give the input. Once the input is
given it takes the value for further execution.
the 4th line the program checks whether the value of $r is present
in $i (venkatraman). If the value is present it jumps to the 9th
line. Otherwise it keeps printing “wrong password” and again asks the user to
enter the value.
line 11 we used for loop to print the numbers from 0 to 9 and to print each
number in a new line. We initialized the $i to 0 and specified the condition
that it should be doing the loop until $i is less than 10 and incremented each
time by 1. The body of for loop has
a print statement to print the value of $i with a \n so that it prints it in a
17, each value from the array variable @ar is passed to the scalar variable $i.
The value is then incremented by 2 and printed on the screen. This way all the
values of the array are incremented by 2 and printed.
The while loop is used to print numbers
from 0 to 5. We first initialize $k to 0 and then specify the condition
($k<5) in the While and perform the print operation and incrementing the
value of $k by 1. This way the values of $k are printed from 0 to 4.
Enter the code exactly as it appears. All letters are case insensitive.