in reply to
Subtract 2 hexadecimal numbers
That would be the devil of a piece of homework ... it could be a real business requirement. And, in any case, it ought to be comparatively simple as “an exercise for the reader / student.”
In any case, you merely need to read the file two lines at a time ... of course, die() if there is no second-line available. Yes, that means two read-statements ... one driving the while loop, and the second one within it. Then in this case you can simply split() each line on the equal-sign character. Presumably you “know” that the second half of the first line will be inst1, and of the second line, inst2, but once again I think that you should check, and die() if this is not so. (Pragmatically speaking, only your program will be in a position to detect errors in its input file, and if there is an error in it, don’t let it go undetected and also don’t let it be blamed on you! If your program runs to completion, it should be an affirmation that the file appears to be correct.)
The final bit of magic is handled by the hex() function, as documented in perldoc -f hex, which will convert your hex-string into an integer. Do this for each of the two hex-strings that you now have in your hand, and print out the difference.