in reply to execute a file, then send terminate command?

Try setting $| to 1 or use IO::Handle
use IO::Handle; STDOUT->autoflush;

UPDATE: ignore my comments .. I read the question incorrectly