in reply to perl to invoke tcl and expect sripts
I don't understand what these three loops are for. If all you want is spawning an external program and waiting for its completion, the simplest way is perlfunc:system.