Free Trial

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

Share this Page URL
Help

Control Structures > Other Postfix Modifiers - Pg. 96

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 state- ment 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 con- trols. 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 state- ments like: print $fh grep {defined $_} @generated_lines; A proper for loop makes the iteration much more obvious: for my $line (grep {defined $_} @generated_lines) { print $line; } Note too that it's not possible to give a readable name to the iterator variable of a