#!/usr/bin/perl

use strict;
use warnings;

my $total_match_len = 0;
my $seq_count = 0;

while (<STDIN>) { # line is in $_
    chomp;
    
    if (/^\@SQ/) { 
	next();
    }
    
    $seq_count++;

    my @fields = split /\t/;
    
    while ($fields[5]=~ m/(\d+)M/g) { 
	$total_match_len += $1;
    }
}

print "Total: $total_match_len. Total number of seqs: $seq_count. Average match len is ".($total_match_len/$seq_count)."\n";




    
    
