It looks like you're already outputting TSV format, aren't you? Anyway, for CSV (and TSV), I'd strongly recommend Text::CSV (also install Text::CSV_XS for speed). You can see one example of how to read and write CSV with it here (and here are a few more examples via Super Search).
In reply to Re: Output to a >CSV file
by haukex
in thread Output to a >CSV file
by pragovnj
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |