amarceluk has asked for the wisdom of the Perl Monks concerning the following question:
You may actually use any scalar value as the conditional of the if control structure. That's handy if you want to store a true or false value into a variable, like this:I understand how that works, but I'm curious as to how people use it, and why it would be used instead of$is_bigger=$name gt 'fred'; if ($is_bigger) {...}
I want to train myself to use good coding practices, but also to understand them, so I'd appreciate any thoughts on using this particular one.if ($name gt 'fred') {...}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using scalar values as conditionals
by Abigail-II (Bishop) on May 28, 2002 at 16:50 UTC | |
by amarceluk (Beadle) on May 28, 2002 at 17:02 UTC | |
|
Re: Using scalar values as conditionals
by samtregar (Abbot) on May 28, 2002 at 18:43 UTC | |
|
Re: Using scalar values as conditionals
by Biker (Priest) on May 29, 2002 at 07:39 UTC |