#!/usr/bin/perl -w use strict; my $c; while (<>) { if (/^>/) { print "$c\n" if defined $c; print /^>(.+?)\s/, "\t"; $c = 0; } else { $c += s/\w//g; } } print $c, "\n";