perl script - data munging

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;

The main problem is your sloppy coding. Mainly this line:

print OUT4 map { "$_-> {arrayid} "} @ {$chromes {$chrom} };

specifically:

"$_-> {arrayid} "

the space between '->' and '{arrayid}' is killing the interpolation because you have it wrapped up in double-quotes. Change it to:

{"$_->{arrayid} "}

I have no idea where you learned to write code with the spaces in odd places:

@ {$chromes {$chrom} };

but you need to stop that:

@{$chromes{$chrom}};

as you can see it will bite you in the butt occasionaly. No spaces between data type symbols, the arrow operator, and brackets. In the above line you can write it likes this if you want less visual clutter:

@{ $chromes{$chrom} };

and when there are no quotes you can get away with stuff like this:

$_-> {arrayid}

but not inside of quotes because a space is a space inside of a quoted string, its not empty whitespace like it is when not quoted.

hey thanx for your suggestions
I do agree what u said. it's working now