use feature ":5.22.2";

$cloc = "/tools/bin/cloc-1.62.pl";  # fix for you

$output_dir = $ARGV[0];
$max_procs = $ARGV[1];

for my $num_proc (2 .. $max_procs) {
    my $civl_time, $ms_time, $isp_time;

    $filename = "$output_dir/CIVL_$num_proc";
    open(OUTPUT, "<", $filename) or die "Cannot open $filename";
    while ($line = <OUTPUT>) {
	if ($line =~/time\s\(s\).*:/) {
	    ($civl_time)=($line =~/time.*:\s*(\S+)\s*$/);
	    last;
	}
    }
    $filename = "$output_dir/ISP_$num_proc";
    open(OUTPUT, "<", $filename) or die "Cannot open $filename";
    while ($line = <OUTPUT>) {
	if ($line =~/real\s.*/) {
	    ($isp_time)=($line =~/real\s(\S+)$/);
	    last;
	}
    }
    $filename = "$output_dir/MS_$num_proc";
    open(OUTPUT, "<", $filename) or die "Cannot open $filename";
    while ($line = <OUTPUT>) {
	if ($line =~/real\s.*/) {
	    ($ms_time)=($line =~/real\s(\S+)$/);
	    last;
	}
    }
    say "$num_proc     $civl_time   $isp_time  $ms_time";
}
