#!/usr/bin/perl
# usage : perl sm_compute_length.pl <FASTA file> <output file>
use strict;
use warnings;

my $s = $/;
$/ = "\n>";
my %h = ();
open (IN, "<$ARGV[0]");
open (OUT, ">$ARGV[1]");
print OUT "Sequence name\tSequence length\n"; 
while ( my $line=<IN>) {
    chomp $line;
    my @F = split(/\n/, $line);
    my $name = $F[0];
    $name =~ s/^>*//;
    my $seq = join("", @F[1..$#F]);
    print OUT $name ."\t" . length($seq) . "\n";     
}
close( IN );
close( OUT );
$/ = $s;


