#! /usr/bin/perl use strict; use warnings; use List::Util qw( sum ); my @values; { # jeweils blockweise einlesen bis zum "end\n" local $/ = "end\n"; while ( my $dataset = ) { my @values = grep { m{^[\d.]+$} } split m{\n}, $dataset; next if !@values; my $average = sum(@values)/@values; print $average, "\n"; } } __DATA__ start 0.23 0.32434 0.234 1.0 end start 0.3423 1.4 end final