Sorry just reading this more carefully now after I ran it. Am I correct in understanding that it only loops through my $i files? The $j files are pushed in @ARGV and are just left there. My problem all along was how to read both $i and $j files and split them using the while $line loop, so that I can move on to the maths later on. Your code seems to only deal with the $i files and loop through them, so how will I be able to build on this to get the $i-$j deviations later on if the $j files are completely ignored? I'm sorry, it's probably there and I'm just not getting it aren't I?