in reply to hash of hashes
As per my views, I would like to tell you my suggestion is:
At the end, you are reading an input file call "EXAMPLE", and fetching each line by line, while doing so, In the code, $id = $_; what happens is $_ is the default variable which carries a trailing record separator from a string, so you have to remove that by using chomp function. that will work.
Don't put off till tomorrow, what you can do today.