Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

6. Control Structures > Other Postfix Modifiers

Other Postfix Modifiers

Don’t use postfix unless, for, while, or until.

The special dispensation to use postfix if in flow-control statements doesn’t extend to any other types of statements. Nor does it extend to any of the other postfix statement modifiers.

The postfix looping modifiers create particular maintenance problems because they place the control flow (i.e., the loop specifier) to the right of the statement it controls. For example, a loop like:

print for grep {defined $_} @generated_lines;

makes it harder to notice the looped flow of control, especially if you also have statements like:

print $fh grep {defined $_} @generated_lines;

A proper for loop makes the iteration much more obvious:

for my $line (grep {defined $_} @generated_lines) {

  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint