-w
Have you tried use strict?
use strict
Did you check the returns of each and every system call?
Did you read the perltrap manpage?
Have you tried the Perl debugger, described in the perldebug manpage?