Summary

Conditionals and loops are the switches and dials of your Perl script. Without them, you can get stuff done, but it'll be the same stuff each time and your script will turn out pretty dull. Conditionals and loops allow you to make decisions and change what your script does based on different input or different situations. Conditional statements are those that branch to different blocks of Perl code depending on whether a test is true or false. You learned about the if, the ifelse, and the ifelsif constructs for building conditionals, as well as the conditional operator ?..:, which can be nested in other expressions, and the use of the logical operators (&&, ||, and and or) as conditionals.

Next, we moved onto loops: specifically the ...

Get Sams Teach Yourself Perl in 21 Days, Second Edition 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.