my @vals = split /\|/, $DocumentReference; for my $V (@vals) { if ($V =~ /\*/) { $V=~s/\*/%/; push @{$where{DocumentRef}{'-like'}}, $V; } else { push @{$where{DocumentRef}{'-in'}}, $V; } } #### $SQL .= ' IN (' . join(", ", @{$where{DocumentRef}{'-in'}}), ') '; #### $SQL .= join(' OR ', map { "LIKE $_ " } @{$where{DocumentRef}{'-like'}});