my @t =([],[],[]);
while () {
chomp;
if (/^>/) {push @{$t[0]}, $_;}
elsif (/^#/) {push @{$t[1]}, $_;}
else {push @{$t[2]}, $_;}
}
my @m = sort(map{$#{$_}} @t);
for my $i(0..$m[$#m]) {
foreach my $e(@t) {
if ($i <= $#{$e}) {print "$e->[$i]\t";}
else {print "\t";}
}
print "\n";
}
__DATA__
>123hello
>26544
#59679
#123hello
oo123
00158669
use strict;
my %result;
while ( chomp (my $line = ) ) {
$line =~ /^(.)(.+)$/;
$result{$1} = [] unless exists $result{$1};
push @{$result{$1}}, $2;
}
foreach my $symbol ( keys %result ) {
print "$symbol$_\t" foreach @{$result{$symbol}};
print $/;
}
__DATA__
>123hello
>26544
#59679
#123hello
oo123
00158669
结果:
#59679 #123hello
oo123
>123hello >26544