in reply to replace comma at the end of my query

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

Replies are listed 'Best First'.
Re: Re: replace comma at the end of my query
by fromsir (Initiate) on May 09, 2003 at 18:37 UTC
    word up! worked beautifully! yep ... i was building my query statement based on whether or not values were present, if the value was present, then i added onto the query so i had that last comma at the end that wasnt need. thanks!