Write a FOR LOOP in Perl
When you create a FOR LOOP you can name the variable anything you like.
In this example, I am naming the variable $ji
for ($ji = 0; $ji < 11; $ji++) {
print "$ji, ";
}
Which prints:
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
In plain English, we are basically saying:
$ji = 0 -The variable $ji equals 0.
$ji < 11 -While $ji is less than 11.
$ji++ -Increment $ji by one each time through the loop (The value of $ji plus one).
Start Copy and Paste Perl Code:
#!/usr/bin/perl
print "Content-type:text/html\n\n";
for ($ji = 0; $ji < 11; $ji++) {
print "$ji, ";
}
exit;
For Loop Perl CGI - See in Action (new window)
Click HERE to comment or discuss at iLoveTheCode GOOGLE Group