Akhthar Parvez K wrote:
There was a typo in my original email. I missed the word "not" which was very 
crucial as always.

Scenario: #1
unless ( (defined $result) && ($test !~ /TEST/) )
 { my $result = "OK";
   print "$result\n";
 }
I thought it was:
UNLESS $result is defined and UNLESS $test does not contain TEST = IF $result 
is not defined and if $test contains TEST.

Scenario: #2
unless (defined $result)
 {
  unless ($test !~ /TEST/)
   { my $result = "OK";
     print "$result\n";
   }
 }
This would work as I thought (UNLESS $result is defined and UNLESS $test does not contain TEST), but not the scenario #1.

If unless confuses you, rewrite it as an if:

if ( (defined $result) && ($test !~ /TEST/) )
 {}
 else
 { my $result = "OK";
   print "$result\n";
 }

If $result is defined and $test does not contain TEST, do nothing;
else set $result to OK and print it.

BTW, it's: UNLESS $result is defined and UNLESS $test does not contain TEST = IF $result is not defined _or_ if $test contains TEST.

!( A && B ) === !A || !B

"===" means "is always equal to"


--
Just my 0.00000002 million dollars worth,
  Shawn

Programming is as much about organization and communication
as it is about coding.

I like Perl; it's the only language where you can bless your
thingy.

Eliminate software piracy:  use only FLOSS.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to