in reply to Printing a int as hex

Your code is not doing anything with the contents of hexfile.txt, but is only reading the contents of %hash, in which there is only one key-value pair. I strongly suspect that this is not really what you were intended, but I cannot know for sure, because you did not say what you wanted to do.