my @where = ("item='$item'", "location='$location'", ... ); my $cSql; foreach( @where ) { $cSql .= ' ' . $_ . ' AND'; } chop $cSql; chop $cSql; chop $cSql;