http://qs321.pair.com?node_id=781183


in reply to Generating complex LDAP queries with Perl

while (my $cond = shift) { $filter = "($op $filter $cond)" if defined $cond; }

The while conditional will exit the loop if $cond is false or undefined so the subsequent test for defined is redundant, $cond will not be undefined inside the loop.   Note that if $cond also contains "0" or "" it will exit the loop.