hmmm if you are just wondering on how to print to a csv file you can just use the IO::File and Text::CSV_XS. If you go check out the documentation of Text::CSV_XS and IO::File what happens is that you scan in your csv file 1 line at a time and each line is put into an array. Anyways, you can do something like
use Text::CSV_XS;
use IO::File;
use strict;
my $csv = Text::CSV_XS->new({sep_char => "\t"});
my %hashed;
open my $in, '<', $input1 or die "Read Failed: $!\n";
while(<$in>)
{
$csv->parse( $_ ) or warn "Bad data: $_\n", next;
my @row = $csv->fields();
$hashed{ $row[0] } = \@row;
}
close $in;
my $fh = new IO::File "> $output";
foreach my $hash ( %hashed)
{
if($hashed{$hash})
{
$csv->combine(@{$hashed{$hash}});
print "$hash has data $hashed{ $hash }->[0]\n";
$fh->print($csv->string, "\n");
}
}
$fh->close;
This is just a basic read in of a csv file that is tab separated. All of the input and csv manipulation can be found in Text::CSV_XS documentation. But to output the file in csv format the easiest way I found was with IO::File.