#!/usr/bin/perl use warnings; use strict; use feature qw{ say }; use List::Util qw{ sum }; my %test; while (<>) { if (/^( *)([0-9]+)\.\.([0-9]+)$/) { my $length = length $1; my ($from, $to) = ($2, $3); $test{$length} += $to - $from + 1; --$test{$length - 4} if $length; } } say sum(values %test), ' tests run.';