in reply to Automate program interaction

maybe you should take a look at
perldoc perlopentut
the paragraphs on pipe opens might contain some of the answers you're looking for.