my $state = 'start'; my $crit = 3; sub getDatensatz{ my ($entry) = @_; my $bool = 0; my $set = ''; my @steigend; for my $line(split(/\r?\n/,$entry)){ chomp $line; my $wert = (split(/\s+/,$line))[-1]; if ($wert >= $crit and $state ne 'high') { $state = 'high'; } elsif ($wert < $crit and $state ne 'low') { if ($state eq 'high') { $bool = 1; } $state = 'low'; } unless($bool){ push(@steigend,$line); } else{ $set .= $line."\n"; } } $set .= $_."\n" for(@steigend); $set .= "\n\n"; return $set; }