in reply to file handing

Not trying to be mean, but you are quite clueless about opening files, how the commands work, and how to use Perl effectively.

I can strongly recommend “Learning Perl”. It taught me a lot, was fun to work with, and made me a better programmer.