>>>>> "Bryan" == Bryan R Harris <[EMAIL PROTECTED]> writes:

Bryan> Is there an "&&=" also?  How about "or="?

There's an &&=, and I thought I'd never use it.

However, one day, I realized that I needed to "normalize" the "true/false"
value of a variable, because I wanted to reduce all possible true/false
values to just 1/0 for easy operations in the next step of the program.

And I came up with this:

        $variable ||= 0; # all false values become 0
        $variable &&= 1; # all true values become 1

OK, so it's weird. :)  I could have just as easy had said:

        $variable = ($variable ? 1 : 0);

But the actual case of needing &&= was cool.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to