Hi guys
I'm trying to print the keys and values of data by using hashes and so on
I was able to retrieve the key but not values. I'm getting result like this
wrong -output
chr1, 1
HASH(0x800d80)-> {arrayid} chr2, 1
HASH(0x800c9c)-> {arrayid} chr3, 1
HASH(0x80177c)-> {arrayid} chr4, 1
HASH(0x801a94)-> {arrayid}
INPUT
arrayids.....chromes
AF0980 chr1
BC0990 chr2
S090TT chr3
VF456T chr4
wanted output
chr1.....AF.....
chr2.....BC... and so on
Perl script I'm using
#!/usr/bin/perl -w
$infile1 = 'chr1.txt';
$outfile4 = 'out4.txt';
open IN3, "< $infile1" or die "Can't open $infile1 : $!";
open OUT4, "> $outfile4" or die "Can't open $outfile4 : $!";
my %chromes;
while (<IN3>) {
chomp;
my ($arrayid, $chrom) = split /\t/;
my $rec = {arrayid => $arrayid};
push @ {$chromes{$chrom}}, $rec;
}
foreach my $chrom (sort keys %chromes) {
my $count = scalar @{$chromes {$chrom} };
print OUT4 "$chrom, $count \n";
print OUT4 map { "$_-> {arrayid} "} @ {$chromes {$chrom} };
}
close IN3;
close OUT4;