# if/else Example (Chapter 4) # Also demonstrates use of "while" $age = 1; while ($age > 0) { # Keep getting voters until -1 is entered for age print "How old are you? "; $age = ; chomp($age); if ($age < 18) { print "So you're not old enough to vote eh?\n"; next; } elsif ($age > 100) { print "You're definately old enough to vote!\n"; $voter++; } else { print "Old enough! Go Vote!\n"; $voter++; } print "You are voter #$voter\n\n"; } #----------------------------------------------------------------------------- # for loop example - just print out the numbers from 1 to 10 for ($i = 1; $i <= 10; $i++) { print "$i "; } print "\n"; #----------------------------------------------------------------------------- # for loop & if example - print numbers from 1 to 100, # with 10 numbers per line for ($i = 1; $i <= 100; $i++) { print "$i "; if ($i % 10 == 0) { print "\n"; } } print "\n";