Wc -Sx- Jones wrote:

> david wrote:
> 
>> how does simply putting a piece of logic in your code and print out an
>> error meesage when a variable match a certain value prove something in
>> Perl is either true nor false? this is simply impossible in Perl because
>> you can never code a 3-way logic.
> 
> 
> use strict;
> use warnings;
> 
> my $test = 0;
> 
> ($test) ? print "\$test exists"
>          : ($test > 0) ? print "\$test greater then zero"
>          : ($test < 0) ? print "\$test less then zero"
>          : print "\$test is zero";
> 
> undef $test;
> 
> (undef, $test) ? print "\$test is defined"
>                 : print "\$test is undefined";
> 
> __END__
> 
> But I was asked not to confuse...
> So ignore this posting...
> 

no i am not going to ignore it :-) 

tell me what exactly have you accomplished and what questions have you 
answered? my statement is:

"you can never code a 3-way logic in Perl"

and then you post a bunch of code without any comment at all except telling 
people to ignore your code. thus, i assume your code answer my question and 
prove that you can code a 3-way logic in Perl which means:

* Perl's 'COND ? THEN : ELSE' conditional operator should never be used 
because it only handles a 2-way logic: true or false

* Perl's equality and inequality operators such as ==,!=,eq,ne should never 
be used because it only handles a 2-way logic: it evaluates their operants 
and produce either a true or false value

* You should never uses 'if(COND)' in Perl because it only evaluates COND to 
either true or false and NOT a 3-way logic as true,false or neither true 
nor false

* You should never uses 'unless(COND)' in Perl for the same reason that it 
only handles a 2-way logic and evaluates to either true or false and 
nothing else

* You should never uses 'EXP or EXP','EXP and EXP','EXP && EXP','EXP || EXP' 
in Perl because they only evaluates to true or false

* More importantly, given this simple program:

#!/usr/bin/perl -w
use strict;

my $i = $ENV{something} ? 1 : 2;

__END__

* I say $i is either 1 or 2 because $ENV{something} can only be true or 
false

* You *might* be saying $i is unknown (or undef) because $ENV{something} can 
be true, or false or neither true nor false which '?:' can't handle. 
correct?

* finally, how useful is this:

> ($test) ? print "\$test exists"
>          : ($test > 0) ? print "\$test greater then zero"
>          : ($test < 0) ? print "\$test less then zero"
>          : print "\$test is zero";

if $test is neither true nor false?

* do you realize "$test" is evaluated to either true or false?
* do you realize "$test > 0" is evaluated to either true or false?
* do you realize "$test < 0" is evaulated to either true or false?

david
-- 
s$s*$+/<tgmecJ"ntgR"tgjvqpC"vuwL$;$;=qq$
\x24\x5f\x3d\x72\x65\x76\x65\x72\x73\x65
\x24\x5f\x3b\x73\x2f\x2e\x2f\x63\x68\x72
\x28\x6f\x72\x64\x28\x24\x26\x29\x2d\x32
\x29\x2f\x67\x65\x3b\x70\x72\x69\x6e\x74
\x22\x24\x5f\x5c\x6e\x22\x3b\x3b$;eval$;

-- 
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