in reply to Sliding window intervals and average values for specific coordinates

If the coordinates are integral and fewer than a few tens of million then you could simply generate a hash which uses coordinates as keys and averages as values then its a simple matter of looking up the hash for each marker:

use strict; use warnings; use lib 'C:\Users\Peter\Tools\BuildManager'; my $data = <<DATA; 12345 12445 0.454 12346 12446 0.326 12347 12447 0.355 DATA my $markers = <<MARKERS; 12435 13455 13532 16135 MARKERS my %dataLU; open my $dataIn, '<', \$data; while (defined (my $line = <$dataIn>)) { chomp $line; my ($start, $end, $avg) = split ' ', $line; $dataLU{$_}{sum} += $avg for $start .. $end; ++$dataLU{$_}{count} for $start .. $end; } close $dataIn; open my $markersIn, '<', \$markers; while (defined (my $line = <$markersIn>)) { chomp $line; next if ! length $line; if (! exists $dataLU{$line}) { print "No value for $line\n"; next; } printf "Marker $line: %f\n", $dataLU{$line}{sum} / $dataLU{$line}{ +count}; } close $markersIn;

Prints:

Marker 12435: 0.378333 No value for 13455 No value for 13532 No value for 16135
True laziness is hard work