in reply to do while debacle
To expand on Abigail-II, you need to sub process_file { my $file = shift; .... if ( $midxfile eq $file ) ... instead of that jobby you wrote.