I don't understand your problem here, this script seems to work, but not if called by some mail trigger?
Anyway, try to use warnings and strict, to get better feedback of the system.
update:
Ah, i see now, it's an update of the thread
Executing system command. Why didn't you post it there?
My advice using strict and warnings still stand, but as your script seems to work, the problem is probably not your script but the way your mailinglist is triggering (calling) your perl script.
"We all agree on the necessity of compromise. We just can't agree on when it's necessary to compromise." - Larry Wall.