revamped for loops

This commit is contained in:
Mark Canlas 2015-06-10 00:05:36 +02:00
parent 75ecb5aa81
commit 66379e80cd

View File

@ -83,13 +83,23 @@ while (condition) {
}
# for and foreach
for ($i = 0; $i <= $max; $i++) {
...
# for loops and iteration
for (my $i = 0; $i < $max; $i++) {
print "index is $i";
}
foreach (@array) {
print "This element is $_\n";
for (my $i = 0; $i < @elements; $i++) {
print "Current element is " . $elements[$i];
}
for my $element (@elements) {
print $element;
}
# implicitly
for (@elements) {
print;
}