© William "Bo" Rothwell of One Course Source, Inc. 2019
William "Bo" RothwellBeginning Perl Programminghttps://doi.org/10.1007/978-1-4842-5055-6_5

5. Flow Control

William “Bo” Rothwell1 
(1)
San Diego, CA, USA
 

Blocks

Control statements are used to handle conditional statements. A conditional statement is something that returns a value (true or false) based upon the current data available to your program.

For example, if the user running the program enters his/her age and this is stored in a variable called $age, we can check to see if $age is greater than 20 and then take some action based upon the outcome.

The following illustrates the different control statements we will cover in this chapter:
  • if

  • unless

  • while

  • until

  • foreach

  • for

A block is a grouping of statements ...

Get Beginning Perl Programming: From Novice to Professional now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.