Hi
I've got the following block (in part!) to read information about column names in a MySQL table.
s/^'(.*)'$/$1/ foreach (@val);
The column names in raw format would output:
What it does is split on commas, and then trim the single 'quotation' marks from the end of each word.
My problem derives from the fact that I have a few records in my databases that include commas. When I run the above sub it splits the record at the end of each word because it picks out the commas, and therefore outputs incorrect information.
My question is, how can I modify the above to split each record only when the comma is found after a single quotation mark? I do not want to split by any comma, only if the comma is found after the single quote.
Thank for any help you can give.
- wil
I've got the following block (in part!) to read information about column names in a MySQL table.
Code:
@val = split (/,/, $val[1]); s/^'(.*)'$/$1/ foreach (@val);
The column names in raw format would output:
Code:
'foo1','foo2','foo3','foo4'What it does is split on commas, and then trim the single 'quotation' marks from the end of each word.
My problem derives from the fact that I have a few records in my databases that include commas. When I run the above sub it splits the record at the end of each word because it picks out the commas, and therefore outputs incorrect information.
My question is, how can I modify the above to split each record only when the comma is found after a single quotation mark? I do not want to split by any comma, only if the comma is found after the single quote.
Thank for any help you can give.
- wil