in reply to sending an email to a perl script
Can you reproduce the problem replacing STDIN with DATA (and a __DATA__ section) and FILE with STDOUT? If so, post the sample here.
Using STDIN to provide the source is somewhat unusual. It would be more conventional to provide an input file name on the command line and open an input file rather than use STDIN.
DWIM is Perl's answer to Gödel
In Section
Seekers of Perl Wisdom