On Wed, 30 May 2001, Paul <[EMAIL PROTECTED]> wrote,
> --- Peter Cornelius <[EMAIL PROTECTED]> wrote:
> I've almost never written code that used && in perl.
> 'and' has a lower precedence, which is usually what you want with
> boolean expressions. It lets you write the same syntax with less line
> noise.
>
> if ($a = func() and $b) { # assigns $a from func(), then checks $b
Assign $a to whatever func() returns, and *if it's true value*,
check $b (also, don't bother to check $b if func() return false).
>
> does something different than
>
> if ($a = func() && $b) { # assigns $a from (func() && $b) compare
If func() returns false, $a set to it, otherwise $b.
Perl doesn't only evaluate the truthness of the expression, but
also returns the value of the last expression evaluated.
s.a.n
--
Hasanuddin Tamir: [EMAIL PROTECTED] - Trabas: www.trabas.com