#!/usr/bin/perl

%dist;
$header="EMPTY";
$len=0;
while (<>) {
    chomp;
    s/\r//;
    $line = $_;
    if (/>/) 
    {
		if ($len>0) 
		{
	    	print "$header\t$len\n";
	    	$dist{$len}++;
		}
		$header = $line;
		$len=0;
    }
    else 
    {
		$line =~ s/\s//g;
		$len = $len + length($line);
    }
}

print "$header\t$len\n";
$dist{$len}++;

$file_out = "stat.txt";
unless(open(OUT, ">$file_out"))
{
	print "cannot open $file_out!!\n";
	exit;
}

foreach my $key (keys %dist) 
{
     print OUT "$key\t$dist{$key}\n";
}
