C
Colossus
Hi,
I have a flat database file this way:
A00469.PE1 SSGGH.PE1 HBG011318 1.26943 39
A00469.PE1 SGGH2.PE1 HBG011318 1.26943 110
A14829.PE1 SSAPOLAI.PE1 HBG004257 1.88791 39
A14829.PE1 DRAPLIPAI.PE1 HBG004257 1.96625 386
A14829.PE1 AF042219.PE1 HBG004257 2.03983 110
The fields are tab separated. I want it this way:
A00469.PE1 SGGH2.PE1 HBG011318 1.26943 110
A00469.PE1 SSGGH.PE1 HBG011318 1.26943 39
A14829.PE1 DRAPLIPAI.PE1 HBG004257 1.96625 386
A14829.PE1 AF042219.PE1 HBG004257 2.03983 110
A14829.PE1 SSAPOLAI.PE1 HBG004257 1.88791 39
I grabbed this piece of code but it doesn't work:
foreach my $MyData (sort { $a->[1] <=> $b->[1] } map{[$_, /^(\d+)/]} @temp)
{
printf "%-15s%5d: %-s\n", ' ', $MyData->[1], $MyData->[0];
}
I understand the problem is regular expression in map. I also
tried to use $b->4 <=> $a->4 because the field I have to order by
is at fourth position but nothing to do ! Could anyone help me please ?
I have a flat database file this way:
A00469.PE1 SSGGH.PE1 HBG011318 1.26943 39
A00469.PE1 SGGH2.PE1 HBG011318 1.26943 110
A14829.PE1 SSAPOLAI.PE1 HBG004257 1.88791 39
A14829.PE1 DRAPLIPAI.PE1 HBG004257 1.96625 386
A14829.PE1 AF042219.PE1 HBG004257 2.03983 110
The fields are tab separated. I want it this way:
A00469.PE1 SGGH2.PE1 HBG011318 1.26943 110
A00469.PE1 SSGGH.PE1 HBG011318 1.26943 39
A14829.PE1 DRAPLIPAI.PE1 HBG004257 1.96625 386
A14829.PE1 AF042219.PE1 HBG004257 2.03983 110
A14829.PE1 SSAPOLAI.PE1 HBG004257 1.88791 39
I grabbed this piece of code but it doesn't work:
foreach my $MyData (sort { $a->[1] <=> $b->[1] } map{[$_, /^(\d+)/]} @temp)
{
printf "%-15s%5d: %-s\n", ' ', $MyData->[1], $MyData->[0];
}
I understand the problem is regular expression in map. I also
tried to use $b->4 <=> $a->4 because the field I have to order by
is at fourth position but nothing to do ! Could anyone help me please ?