in reply to Bit of maths between two files

I don't think any of your posts so far have made it clear exactly what you are trying to accomplish. Perhaps you could show what you want the new file to look like for your sample File1 and File2?

Some hints that may or may not apply depending on what you actually are trying to do:

If you want to produce a File3 where line X depends on line X of File1 and line X of File2, you need to be going through File1 and File2 at the same time, not in separate loops. See the question from a couple weeks ago: Combining Lines from Two Docs into Another

Make sure to only use "my" variables in their scope; they only last until the end of the innermost enclosing {}. If you try to use them beyond that point, you'll get the global variable of the same name instead. Put "use strict;" and "use warnings;" at the top of your script to be notified when you make this mistake (and others).