Hmm, it might be possible with regexes if your SQL statements are always quite simple, but facing such an issue, I would probably go for real parsing.
This means you would have to write an SQL grammar (or possibly finding one on the Internet) and use a parser module such as, for example, Damian Conway's Parse::RecDescent (http://search.cpan.org/~jtbraun/Parse-RecDescent-1.967009/lib/Parse/RecDescent.pm).
Or, perhaps better (but I have not tried any of these), SQL parsing modules such as http://search.cpan.org/~team/Parse-SQL-0.002/lib/Parse/SQL.pm, http://search.cpan.org/~rehsack/SQL-Statement-1.405/lib/SQL/Parser.pm, etc., there are many of them on the CPAN, I do not know which would be really useful.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.