package RUM::Common;

use strict;
use warnings;

use Exporter qw(import);
our @EXPORT_OK = qw(getave);

=head1 FUNCTIONS

=over 4

=item getave

TODO: Document me

=cut 

sub getave {
    my ($spans_x) = @_;

    my @SS3 = split(/, /, $spans_x);
    my $spanave = 0;
    my $spanlen = 0;
    for(my $ss3=0; $ss3 < @SS3; $ss3++) {
	my @SS4 = split(/-/, $SS3[$ss3]);
	$spanave = $spanave + $SS4[1]*($SS4[1]+1)/2 - $SS4[0]*($SS4[0]-1)/2;
	$spanlen = $spanlen + $SS4[1] - $SS4[0] + 1;
    }
    $spanave = $spanave / $spanlen;

    return $spanave;
}

1;

package RUM::Common;

use strict;
use warnings;

use Exporter qw(import);
our @EXPORT_OK = qw(getave);

=head1 FUNCTIONS

=over 4

=item getave

TODO: Document me

=cut 

sub getave {
    my ($spans_x) = @_;

    my @spans = split(/, /, $spans_x);
    my $ave = 0;
    my $len = 0;
    for my $span (@spans) {
	my ($start, $end) = split(/-/, $span);
	$ave = $ave + $end*($end+1)/2 - $start*($start-1)/2;
	$len = $len + $end - $start + 1;
    }
    $ave = $ave / $len;

    return $ave;
}

1;

Rename some local vars for clarity
Rename some local vars for clarity
