Hrm, just guessing, but are you building your query like the following:
# @TERMS defined elsewhere my $query = 'SELECT '; foreach my $term (@TERMS) { $query .= "$term,"; } $query .= 'WHERE foo = ?';
If so, try this instead:
my $query = 'SELECT ' . join(',', @TERMS) . 'WHERE foo = ?';
As for your orginal question, try using '\z' instead of '$'. '$' is supposed to match the end of a line. In other words, a new line. '\z' is usually more correct. The two are often interchangable, but will bite you when you confuse the two.
----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer
Note: All code is untested, unless otherwise stated
In reply to Re: replace comma at the end of my query
by hardburn
in thread replace comma at the end of my query
by fromsir
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |