Prof. Alfred J Bird, Ph.D., NBCT [email protected] http://it441-f11-campbell.wikispaces.umb.edu/ Door Code for IT441 Students – 142864* Office – Wheatly 2nd floor 096-03 Office Hours – MW 3:00PM to 4:00PM exit (0); die $string; A very helpful construct is the increment/decrement statement $i++ is equivalent to $i = $i+1 $j = $i++ $j = ++$i $j = $i - $j = - - $i $x > $y $x < $y $x >= $y $x < =$y $x == $y $x != $y $x gt $y $x lt $y $x ge $y $x le $y $x eq $y $x ne $y $x and &y $x && $y $x or $y $x || $y Not $x !$x What is a control statement? Types of control statements: if while for if if else if ( condition ) { action } if (condition ) { action } else {another action } if elsif else if ( condition ) { action } elsif (another condition ) { another action } … else { a further action } while loops while ( condition ) { action } $i=1; while ($i<=5) { print $i, “\n”; $i++; } $_ is the default variable for many functions while ( $line = <STDIN>) { chomp ($line); … } while (<STDIN>) { chomp; … } for loop for ( init_exp ; test_exp; step_exp) { action } for ($i=1; $i<5; $i++) {print $i, “\n”;} foreach my $number (1..10) { print “The number is: $number \n”; } Read Chapter 3 “Control Flow Constructs” pp 53-79 Exercises 1, 2 & 3 on page 79
© Copyright 2026 Paperzz