Will you know which columns numbers you want to keep? If so, you can just return the required portion of the array and use it for average calculation.
perl -e '@array = qw (hello world 1 2 3); @req = qw (2 3 4); $str = pr
+int join (",",@array[@req]), $/;'
__END__
1,2,3
In the above code i have an array called array then i have a required columns array called req. @array[@req] returns a list with values from the required columns.
Regarding the removal of "." from the header, at what point do you want to do it? Before you start reading the CSV into DBI or when you write out? Before you use it in DBI would require you to do an inplace edit. Writing out the correct header (without period) should be very easy. A simple regex on the your "variable column" array.
perl -e '@wperiod = qw (hi.1 hi.2 hi.3); print join (",", map {s/\.//g
+; $_} @wperiod), $/;'
__END__
hi1,hi2,hi3
-SK
|