in reply to Re^5: setting up boolean parameters from keywords
in thread setting up boolean parameters from keywords
next if /^#/; last if /#{5,}/; warn "B-Fruit: '$_'\n" foreach grep { /^b/ } @fruits; build_acty_for_callout_at_sub_loc_hash( $fxhr, $previous_data_ar, \%acty_for_callout_at_sub_loc ) unless %acty_for_callout_at_sub_loc;
Personally, it annoys me to read a line of Perl and midway through the line, or almost at the end, find such a qualifier term. (All that thinking through of what is going to happen and then you read if SOME CRAZY CONDITION THAT PROBABLY WON'T HAPPEN;) So, my preference is to spread such statements over two lines, so that your eyes see early on the left side the critical pieces of the statement. Like so:
warn "B-Fruit: '$_'\n" foreach grep { /^b/ } @fruits;
This particular example is one I would usually avoid breaking over two lines! Generally, I have lines like this in my code for debugging purposes, and usually they are commented out except for times when I want the extra verbiage to stand out. For these special cases, I only have to comment out one line if I keep the construct to one line instead of two. :-)
A drawback with 'post-conditions' is that once you decide you would like to do two things instead of one, you must invert the construct back to the normal view, i.e.
foreach ( grep {/^b/} @fruits ) { print LOGFILE "Found B-Fruit '$_'\n; warn "B-Fruit: '$_'\n"; }
So at the end of the day, I believe you will find it is one of Damian's "Perl Best Practices" to avoid use of this construct except for super simple statements like last unless @words
|
|---|