On 9/21/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: snip > If I am joining this with a ',' and saving renaming the text file to CSV will > help or is > there any other way to do it? snip
While that will work, you will have problems if your fields contain a , or a an embedded newline. This is why real CSV uses quotes around the fields, but you can't just through quotes around the fields because they might contain quotes already (they need to be escaped). Lets say you have a set of fields in @fields and want to print them to stdout as a csv record. You could do it like this: print join(',', map { s/"/""/g; qq("$_") } @fields), "\n"; snip >Also I need to bold the header in my CSV. snip CSV is a plain text format, there is no way to bold anything. If you are using the CSV file solely to get the data into MS Excel and you want to be able to control the style of the document then HTML is a better format for you (although, using Spreadsheet::WriteExcel* is the best option in that case). #!/usr/bin/perl use strict; use warnings; sub th { "<th>$_[0]</th>" } sub td { "<td>$_[0]</td>" } sub trow { my $func = shift; return "\t\t\t<tr>" . (join '', map { $func->($_) } @_) . "</tr>\n"; } open my $out, ">", "report.html" or die "could not write report.html:$!\n"; print $out "<html>\n\t<head>\n\t\t<title>report for" . localtime() . "</title>\n\t</head>\n\t<body>\n\t\t<table>\n"; print $out trow(\&th, split /\s\s+/, <DATA>); print $out trow(\&td, split ' ') while <DATA>; print $out "\t\t</table>\n\t</body>\n</html>\n"; __DATA__ Hostname IP address Physical Address. inxp1233 XXX.XXX.XXX.XXX Mac-address inxp1432 XXX.XXX.XXX.XXX Mac-address inxp1232 XXX.XXX.XXX.XXX Mac-address * http://search.cpan.org/dist/Spreadsheet-WriteExcel/lib/Spreadsheet/WriteExcel.pm -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/