in reply to export table to text.

oshalla++ for his post. All you need to do is add some html, especially the p-tag for text and c-tag for code, to make your post somewhat readable. Hint: you can edit your message

As a general comment, whatever you want to achieve, using a shell script between your perl script and the database is definitely the wrong idea. You will lose information in this double conversion and you have to search long for cases where a shell script can do better than native perl code.

The advice probably everyone here will give you: Use a perl module like DBI to read your database. You find usage info and sample code within its documentation and everywhere on perlmonks, on the wider internet and in many perl books.