use IO::File; use Text::CSV_XS; for (@ARGV) { my $out_fname = $_.'.dshield'; my $inf = new IO::File ( $_,'<' ) or die "Cannot read $_"; my $outf = new IO::File ( $out_fname ,'>' ) or die "Cannot write $out_fname"; my $csv_in = new Text::CSV_XS; # defaults work for most CSV's my $csv_out = new Text::CSV_XS({sep_char=>"\t"}); # use tabs until ($inf->eof) { my $line = $csv_in->getline($inf); $csv_out->print($outf, $line); } } ## IO::File objects close automatically when they go out of scope