in reply to logical non-short-circuit operators
my $num = $recFono->field_as_text('102'); my $type = $recFono->field_as_text('104'); if ($num && $type) { something(); }
This has the benefits of
- Letting the assignments standing out clearly
- Shortening the individual lines, making them easier to read
- Clearly conveys that you want the arguments of the logical operator evaluated independent of truth/falsehood of the first one
If you really want it on one line, you can write your own logical function:
sub myor { $_[0] or $_[1]; } if (myor( ..., ...)) { }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: logical non-short-circuit operators
by RMGir (Prior) on Nov 02, 2011 at 18:37 UTC | |
by moritz (Cardinal) on Nov 02, 2011 at 19:19 UTC | |
Re^2: logical non-short-circuit operators
by december (Pilgrim) on Nov 02, 2011 at 18:55 UTC | |
by moritz (Cardinal) on Nov 03, 2011 at 09:19 UTC | |
Re^2: logical non-short-circuit operators
by sundialsvc4 (Abbot) on Nov 03, 2011 at 14:18 UTC | |
by BrowserUk (Patriarch) on Nov 03, 2011 at 15:08 UTC |
In Section
Seekers of Perl Wisdom