use File::Basename;
open(IN,'<vmc.csv');
while (<IN>){
    chomp;
    $line=$_;

    unless ($line=~ /#/){
	@files=split(',',$line);
	$files[0] =~ s/^\s+|\s+$//g;
	$files[1] =~ s/^\s+|\s+$//g;
	$files[2] =~ s/^\s+|\s+$//g;
        $files[0]=~ s/.fit/_conf.fit/g;
        $files[1]=~ s/.fit/_conf.fit/g;
        $files[2]=~ s/.fit/_conf.fit/g;
        $out0= "Y_".fileparse($files[0],".fit").".fit";
        $out1= "J_".fileparse($files[1],".fit").".fit";
        $out2= "K_".fileparse($files[2],".fit").".fit";
	print "$files[0] $out1\n";
	print "$files[1]\n";
	print "$files[2]\n";
      
        $imcopycmd="imcopy $files[0]"."[1] "."$out0; imcopy $files[1]"."[1] "."$out1; imcopy $files[2]"."[1] "."$out2;";
	print "$imcopycmd\n";
        $output=`$imcopycmd`;
        print "$output \n";
    }
}
close(IN);
