It's quite dangerous to readability to use flow control structure that are tail-loaded. As you said, they would require reading from right-to-left (or bottom-to-top), but Perl is otherwise arranged in a top-to-bottom, left-to-right order. Tail-loaded control structures are only acceptable, if ever, when the body is minimal. Your second snippet is a prime example of horrible code.
So flow control modifiers can't be tacked onto other flow control structures, including other flow control modifiers.
Correct bracketing:
if ( $a ) { print for @b; }
The following might be an option:
next if !$a; # Or `return` print for @b;
If you don't set $\ and $,, the first snippet above is equivalent to:
print @b if $a;
In reply to Re: why not listed foreach and if?
by ikegami
in thread why not listed foreach and if?
by vincentaxhe
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |