# File: controlFor.pl # Title: Ask for an integer n. Count till n. # Author: Mihaela Malita # Count till? 5 # 12345..12345 # Bye print "Count till? "; $n = ; chop($n); for (1..$n) { # for every element in list print $_; # $_ is the default counter of the loop } #use general for for ($i = 1; $i <= $n ; $i++) { # i is the counter of the loop print $i; } # another way: you can make a List before my @count = (1..$n); # makes list (1,2,3,4,5) for $i (@count) { # for every element in list print $i; } # use foreach foreach (@count) { # for every element in list print $_; # $_ is the default counter of the loop } print "\nBye"; exit;