I am new to perl and am looking for a starting point or approach to my problem.
We have an application that generates a SQL statement to run a data extract. The SQL has multiple ? throughout. These are replaced by a list of values that are comma delimited. I am looking for a way to take the first value in the list to replace the first ? in the SQL. Second value in the list replaces the second ?, and so on. There are between 20 and 50 places to replace the data in each SQL statement and it is very time consuming.
I'd like to find a way to do the replacement, but am not sure how to approach it. I would think given a file.sql and a file.input I could generate finished.sql. Can somebody point me in the right direction on this, please?
My initial thoughts are to read the data list into an array, and replace the ? with $data[0], $data[1] or something like that, but am unsure how to do that incrementally in order. Is this a good approach or is there a better way to do this?
We have an application that generates a SQL statement to run a data extract. The SQL has multiple ? throughout. These are replaced by a list of values that are comma delimited. I am looking for a way to take the first value in the list to replace the first ? in the SQL. Second value in the list replaces the second ?, and so on. There are between 20 and 50 places to replace the data in each SQL statement and it is very time consuming.
I'd like to find a way to do the replacement, but am not sure how to approach it. I would think given a file.sql and a file.input I could generate finished.sql. Can somebody point me in the right direction on this, please?
My initial thoughts are to read the data list into an array, and replace the ? with $data[0], $data[1] or something like that, but am unsure how to do that incrementally in order. Is this a good approach or is there a better way to do this?