in reply to Empty output files
I notice you have "use warnings;" commented out. Don't do that. The warnings are trying to tell you about potential problems in your code, I always use it. I won't run code that doesn't run warning free.
Also you might want to consider adding "use diagnostics;" to your code. This will give you a more in depth explanation of errors and warnings in your code.