On Tue, Nov 24, 2009 at 11:12 AM, Chad Morland <cmorl...@gmail.com> wrote:
> I figured AND(&&) operators had to match both conditions in order to be > true, hence me trying to use OR(||). I guess it's the opposite? > > On Tue, Nov 24, 2009 at 12:03 PM, Steve Bertrand <st...@ibctech.ca> wrote: > > > Chad Morland wrote: > > > my $vhost_server_name = qw(somedomain.com); > > > my @vhost_server_alias_array = qw(www.somedomain.com *.somedomain.com > > > sub.somedomain.com); > > > > > > foreach my $vhost_server_alias (@vhost_server_alias_array) { > > > if (($vhost_server_alias ne "www.$vhost_server_name") || > > > > Replace your || (or) with && (and): > You're correct: AND matches both conditions. As originally written, the first entry in the list "www.somedomain.com" does not match the first condition. It does match the second condition, though. So the OR is true because the second condition is true. The second entry in the list has the same logic: the first condition returns true, and the second condition returns false. Since the first condition returned true, the OR returns true. The code doesn't want to match ANY of the patterns. It needs a truth table like this: www * result 0 0 0 0 1 0 1 0 0 1 1 1 That truth table matches the AND operator. Does this make sense? -- Robert Wohlfarth