If you just want to generate output from SQL queries, I recommend using Querylet instead.
But for the problem at hand, maybe you want to use the join function so you don't miss spaces at parts of your header sequence?
Your program, when reduced to the relevant parts looks like this:
$header_rec .= "NAME "; $header_rec .= "ID "; $header_rec .= "REGION "; $header_rec .= "UNIT"; $header_rec .= "STATUS "; print "[$header_rec]\n";
If I change it to the below, it works for me as expected:
my @columns = ('NAME','ID','REGION','UNIT','STATUS'); print join( "\x09", @columns), "\n"; # or alternatively print "[@columns]\n";
Also, you'll be well-advised to use a tab character (\0x09) instead of a blank to separate your output.
In reply to Re: How to print header to a CSV file
by Corion
in thread How to print header to a CSV file
by Rocko19
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |