Note use of qq rather than quoted stringsmy @words = split(/\s+/, $_[0]); # <-- Better to split on any whi +tespace my $newquery = qq[SELECT "taskID" from "repair" WHERE ("repairKEYWOR +D1" = '')]; foreach my $currentword (@words) { # <-- Current word goes outsid +e brackets $currentword =~ /^([\w]+)$/; $newquery .= qq[ or ("repairKEYWORD1" = '$currentword')]; $newquery .= qq[ or ("repairKEYWORD2" = '$currentword')]; $newquery .= qq[ or ("repairKEYWORD3" = '$currentword')]; }
Does it work any better?
Update Splits better on /s than /S... but you saw that
In reply to Re: foreach problem?
by Tyke
in thread foreach problem?
by fastkeys
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |