in reply to "if" to "case ... end"

Did you think about using an existing SQL parser like SQL::Statement::Structure ?

searching gives plenty of hits for "SQL parser Perl" also in PM's archives...

Cheers Rolf

( addicted to the Perl Programming Language)