Internet Pages on Perl Control Structures


Chih-Tsun Huang’s Perl class

http://larc.ee.nthu.edu.tw/~cthuang/perl/03_control_structure.html


About Computing and Technology page

http://perl.about.com/od/perlforbeginners/l/aa062501a.htm


Program the Web – a bare bones page

http://www.internetz.com/programming/perl/control.html


The Perl Language Homepage

http://www.perl.com/download.csp


ActivePerl User Guide (check the entry perlsyn - Perl syntax)

file:///c:/Perl/html/index.html


The CPAN page has color!

http://perldoc.perl.org/perlsyn.html


Here is an example program that demonstrates control blocks.


#!/usr/local/bin/perl

#Demonstrate control blocks


#while loops

$count = 10;


while ($count >= 1) {

   print "$count ";

   $count--;

} #end while

print "Blastoff.\n\n";


while ($number1 ne 'quit') {

  print "Pick a number or type 'quit'.\n";

            chomp ($number1 = <STDIN>);

            print "You picked $number1.\n\n";

} #end while


#until loops

$count = 10;


until ($count == 0) {

 print "$count ";

 $count--;

} #end until

print "Blastoff.\n\n";


until ($number2 eq 'quit') {

  print "Pick a number or type 'quit'.\n";

            chomp ($number2 = <STDIN>);

            print "You picked $number2.\n\n";

} #end until