I'm afraid your description is a bit too tangled for me to follow, not sure which of the various csv files is needed and how the sqlite database fits in. It seems to me that your best bet is to treat *all* of the data as a database. Use DBD::CSV to read the text files and write the pipe-delimited files. You can even do joins of the two input text files so you aren't reading them in tandem. This method would allow you to define the tables and the relations between them, even if some of the tables consist of only a single field. If you can come back with a schema - a list of the columns in the various data sources and the relations between them, I (and probably others) can help get that into a form that will have DBD::CSV and DBD::SQLite talking to each other.