Deleting columns from CSV file

Hi All,

Am working on perl script which should delete columns in existing CSV file.
If my file is :

AA,BB,CC,DD
00,11,22,33
00,55,66,77
00,99,88,21

AA,BB... are all my headers can come in any order (e.g AA,CC,BB...) and rest are values. I want to delete column CC...
Can anybody help me on this?

perl -F, -lane'
    ($idx) = grep $F[$_] =~ /^CC$/, 0 .. $#F
      and @range = grep $_ != $idx, 0 .. $#F
      if $. == 1;
    print join ",", @F[@range];
  ' infile  

Do it systematically

1) open the file with filehandle
2) read the first line and split on ","
3) go through the array, check for "CC", if found, get the index of the array where its found and save to variable
4  while iterating through the rest of the lines
        split each line by ","
        remove the array item according to index found in step 3)
        join the array back
        print output