#!/usr/bin/perl -w

use strict;

#my $i, $j;  # Note: this doesn't bind correctly - only the first ($i)

my $i=0, my $j=10;

print "** Using a simple FOR loop:\n";
for ($i=0; $i < $j; $i+=2) {
    if ( ($i % 10) == 0) {
	print "i=$i\n";
    } else {
	print "$i is not a product of ten!\n";
    }
}

print "** Using a simple WHILE loop:\n";
$i=0; $j=5;
while ($i < $j) {
	print "i=$i\n";    
	$i++;
}


print "** Using a simple UNTIL loop:\n";
$i=0; $j=5;
until ($i >= $j) {
	$i++;
	print "i=$i\n";    
}

print "** Using a simple FOREACH loop with a series\n";
foreach $i (-5..$j) {
    print "i=$i\n";    
}

print "** Using a simple FOREACH loop with an array\n";
my @arr=("x", "y", "z");
foreach $i (@arr) {
    print "i=$i\n";    
}

print "** Just print an array:\n";
print @arr; print "\n";

