in reply to Running Perl in an Expect loop

There are several frameworks in CPAN allowing the execution of Perl code in other processes (local and remote). Check for instance Object::Remote.