Hi,
I have a file with the following data:
a:1:m
b:2:n
c:1:h
d:2:k
f:2:r
I want the output to be based on the matching of the second column:
1
m,h
2
n,k,r
I am trying this way, but not getting there:
#!/usr/bin/perl
my @second;
$file="a.txt";
open (DAT, $file) || die ("Could not open file $file");
$i=0;
for $line (<DAT>) {
my ($a,$b,$c)=split(/:/,$line);
chomp $c;
push (@ram, "$c");
%ba = ("$b", @second);
}
while (($key,$value) = each (%ba)) {
print $key.",".$value;
print $key;
}
print %ba;
Any help will be greatly appreciated