my @what = split(/\s+/, $what); shift @what if $what[0] eq ''; # skip leading empty fields my $first = 1; foreach (@what) { push (@$where, 'AND') unless $first; push (@$where, [ { subject => ['LIKE', "\%$_\%"] }, 'OR', { message => ['LIKE', "\%$_\%"] }, ]); $first = 0; } $dbx->select({ fields => 'reference, subject, name', table => 'boardmessage', where => $where, });