in reply to perl script like a "shell proxy"
Perhaps searching for that might reveal some ideas. Perhaps the source of Devel::REPL is inspiring as well.