Skip to Content
Beginning Perl
book

Beginning Perl

by Curtis Ovid Poe
September 2012
Beginner
744 pages
15h 48m
English
Wrox
Content preview from Beginning Perl

Chapter 5

Control Flow

WHAT YOU WILL LEARN IN THIS CHAPTER:

  • Working with if/elsif/else expressions
  • What are and when to use for/foreach loops
  • Understanding and working with while/until loops
  • Understanding the various statement modifiers and how to use do while/do until
  • What are given/when statements and statement modifiers and when to use them

WROX.COM CODE DOWNLOADS FOR THIS CHAPTER

The wrox.com code downloads for this chapter are found at http://www.wrox.com/WileyCDA/WroxTitle/Beginning-Perl.productCd-1118013847,descCd-DOWNLOAD.html on the Download Code tab. The code for this chapter is divided into the following major examples:

  • Example_5_1_unique.pl
  • Example_5_2_arrays.pl

From previous chapters, you now understand some of the basics of Perl, but now you get closer to the heart of programming. When you program, you constantly make decisions loop over data based on those decisions. That’s what this chapter is all about: how Perl makes decisions and looping over data.

USING THE IF STATEMENT

This section starts with boolean logic. As explained in Chapter 4, the following values are considered “false” in Perl:

  • undef
  • "" (the empty string)
  • 0
  • 0.0
  • "0" (the “string” zero)

Some languages have specific boolean objects, or TRUE and FALSE identifiers. Perl does things a little differently. As you work through the examples, try to see what Perl does and why. If you have experience with programming languages that have a different approach, consider the strengths and weaknesses of the different ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Perl

Mastering Perl

brian d foy
Learning Perl 6

Learning Perl 6

brian d foy
Perl & LWP

Perl & LWP

Sean M. Burke
Perl by Example

Perl by Example

Ellie Quigley

Publisher Resources

ISBN: 9781118235638Purchase book