#!/usr/bin/perl

use List::Util qw(first max maxstr min minstr reduce shuffle sum);

while (glob "*") {
    $dir = $_;
    next unless -d $dir;
    open G, '>', "$dir.dat";
    while (glob "$dir/result-agregate-*") {
	$file = $_;
	($x) = m/(\d+)$/;
	open F, '<', "$file";
	@A = ();
	@S = ();
	while (<F>) {
	    ($avg, $stddev) = m|avg=1/([^ ]+).*stddev=([\d/.]+)|;
	    #print G "$x $avg ",eval($stddev),"\n";
	    push @A, $avg;
	    push @S, eval($stddev);
	}	
	printf G "%d %5.2f %7.5f\n", $x, sum(@A)/scalar @A, sum(@S)/scalar @S;
	close(F);
    }
    close(G);
}
