in reply to sending an email to a perl script
Since you're not using an absolute path, it's possible that your working dir is different in each case. In addition to the above suggestions, I'd suggest using the full path of the filename when opening it.
Joe
In Section
Seekers of Perl Wisdom