Scott, I've found the AnyData module (search CPAN for AnyData) to be great for CSV. It can read and write CSV or XML, either tied to hash variables or through a DBI interface, as well as reading and writing to HTML tables. I've noticed that it uses the following rules for CSV:
* If field to write contains no internal commas, write to file without surrounding quotes. * If string contains commas, surround field with double-quotes. * If string contains both commas and double-quotes, surround with double-quotes and indicate literal double-quotes as two quotes in a row. For example, a row consisting of these string values: Here's a value One with "quotes" Another, with a comma Another, w/commas, and "quotes" would be written (on one line) as Here's a value,One with "quotes","Another, with a comma","Another, w/commas, and ""quotes""" Make sense? Couldn't tell you what the code looks like for parsing. - John -----Original Message----- From: Scott Lutz [mailto:[EMAIL PROTECTED]] Sent: Monday, December 17, 2001 3:05 PM To: Beginners (E-mail) Subject: output into a csv file here is a snip of code that opens a .csv file, massages some of the data a bit, and then writes it back to a new .csv file. The problem is that I can't figure a quick way to print out with commas where they should be. Some suggestions would be great! __snip__ foreach $line (@data) { chomp; my @string = split(/,/, $line); if (@string[0,1] eq "" ) { next; } else { $copy_data = $string[0]; $string[34] = $copy_data; push (@output, "@string"); print "Line $count parsed with FIRST -> $string[0] and LAST -> $string[34]\n"; } $count++; } __end_snip__ Scott Lutz technical support Pacific Online http://www.paconline.net -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This message may contain information which is private, privileged or confidential and is intended solely for the use of the individual or entity named in the message. If you are not the intended recipient of this message, please notify the sender thereof and destroy / delete the message. Neither the sender nor Sappi Limited (including its subsidiaries and associated companies) shall incur any liability resulting directly or indirectly from accessing any of the attached files which may contain a virus or the like. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]