Now I finally found some time to try Georges new code.

And as I needed a way to generate a worktodo.ini, I though that I could pull the code from the old factorer that reads the SoB.dat so I could avoid having to start the old factorer, stop it again, copy a part of it's output to a temporary file and using garo's awk command.

Well, it was no problem finding the code, but it seemed fu..... ugly, so I decided to start over in Perl. The result is the following Perl-script for appending (i.e. you can add new tests before it's done with the old ones) new tests to worktodo.ini:
Code:
#! /usr/bin/perl

use strict;
use warnings;

my $kval;
my $current_n;
my $count;
my @tests;

if ($#ARGV != 3) {
    print("Usage: make_worktodo.pl <n_low> <n_high> <factor depth> <factor value>\n");
    print("$#ARGV\n");
    exit(-1);
}

my $n_low = $ARGV[0];
my $n_high = $ARGV[1];
my $depth = $ARGV[2];
my $value = $ARGV[3];

open(DATFILE, "<SoB.dat") or die "Couldn't open dat file\n";

# Remove the first 3 lines
<DATFILE>;
<DATFILE>;
<DATFILE>;

my $line;
while ($line = <DATFILE>) {
    chomp $line;
    if ($line =~ /^k=(\d+)/) {
	$kval=$1;
	$current_n = <DATFILE>;
    } else {
	$line =~ m/\+(\d+)/;
	$current_n += $1;
    }
    if (($current_n < $n_high) and ($current_n >= $n_low)){
	push @tests,{ 'k' => $kval, 'n' => $current_n };
	$count++;
    }
}
close(DATFILE);

print "$count numbers with $n_low <= n < $n_high\n";

my $removed = 0;
my $factor_k;
my $factor_n;
my $test;

print "Searching for known factors in results.txt...\n";
open(RESULTSFILE,"<results.txt") or die "Failed to open factor file!\n";
<RESULTSFILE>;
while ($line = <RESULTSFILE>) {
    next unless $line =~ m/^\d+\s+(\d+)\s+(\d+)/;
    $factor_k = $1;
    $factor_n = $2;
	  
    next if (($factor_n >= $n_high) or ($factor_n < $n_low));
	  
    for(my $i = 0; $i < $count; $i++) {
	next unless (defined($tests[$i]));
	if (($tests[$i]{'k'} == $factor_k) and ($tests[$i]{'n'} == $factor_n)) {
	    delete $tests[$i];
	    $count--;
	    $removed++;
	}
    }
}
close(RESULTSFILE);
print "Removed $removed numbers using the factor file\n";

print "$count numbers with $n_low <= n < $n_high\n";
@tests = sort { $$a{'n'} <=> $$b{'n'}; } grep { defined } @tests;

open(WORKFILE,'>>worktodo.ini');
foreach $test (@tests) {
    print WORKFILE "Pfactor=$$test{'k'},2,$$test{'n'},1,$depth,$value\n";
}
close(WORKFILE);
It takes four arguments, n_low, n_high, factor_depth and factor_value.

It works on my Linux box, and just might be portable (the only thing I can see that might need changing on windows is \n as end-of-line).

I find this quite easy, and thought some of you might like it too. As usual this is free software.