http://www.perlmonks.org?node_id=481606

DrAxeman has asked for the wisdom of the Perl Monks concerning the following question:

In my @cols array, each element has an _ in it. I want to convert this into an , during output. My code looks like:
my %avgsHash; @avgsHash{ @cols } = map {to_decimal($_)} @avgs; print "Server,Statistic,Average\n"; printf("%s,%f\n", $_, $avgsHash{$_}) for @cols;
Current output looks like:
Server,Statistic,Average ERRWWW_CPUPCT,5.1221 ERRWWW_RAMPCT,12.2332

Currently I'm piping my output through "sed" to modify this. I'm hoping that I can get it done in the code. I've tried a s/_/\,/g during the printf, but that failed.

Thanks