in reply to order of operations with conditionals at the end
if is not an operator. It's part of the syntax of an if statement. An if statement evaluates its condition first, then evaluates the rest if and only if the condition evaluated to something true.
EXPR if CONDEXPR;
is exactly the same as
(CONDEXPR) and EXPR;
By the way,
my $var ... if ...;
is not allowed. (Same goes for unless.) You should be using
my $message; $message = "Congrats" if defined $reward;
or
my $message = $reward ? "Congrats" : undef;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: order of operations with conditionals at the end
by JavaFan (Canon) on Mar 26, 2012 at 23:34 UTC | |
by ikegami (Patriarch) on Apr 04, 2012 at 20:01 UTC | |
by JavaFan (Canon) on Apr 04, 2012 at 20:51 UTC | |
by AnomalousMonk (Archbishop) on Apr 04, 2012 at 21:22 UTC | |
by ikegami (Patriarch) on Apr 04, 2012 at 21:16 UTC |