in reply to file comparisons: - making it faster

Some more general pointers:

Start your code with:

use strict; use warnings;

Code like if (unlink($remove1) == 1) { ... is better written as

if ( -e $remove ) { unlink $remove or die "unable to delete $remoe: $!\n"; }

Use lexical file handles instead of global ones

The call  my ($w1, @w1) = read_query_file($file2); makes no sense; the sub is not returning anything, only the side effects inside the sub are used!

The use of $a, $b, $c is not needed. Use describtive variable names and don't use you many...

Paul