use IPC::Open2; local (*RD, *WR); my $child = open2(\*RD, \*WR, 'passwd'); # RD and WR are now pipes connected to STDOUT/STDERR and # STDIN respectively of the child process. $child contains # the PID. my $prompt = ; # not caring what the prompt is, here print WR "password\n"; $prompt = # prompted again print WR "password\n";