in reply to Passing password with command

if your program really reads from STDIN (update: instead of reading the terminal input directly - some unix programs read from /dev/tty for sensitive information, for example) and the command name really starts with a dash and you wouldn't try to redirect the output, it might work.

Try this:

my $pwd1 = "pwd1"; my $pwd2 = "pwd2"; open(FOO, "|$command") or die "open command failed: $!"; print FOO "$pwd1\n$pwd2\n"; close FOO;
update 2: redirecting the output shouldn't have any serious consequences, but it may help in that it may show error messages that otherwise might get redirected