use IPC::Run qw(start pump finish); my @args; push @args, $app_path; my ($in, $out, $err); # starting the application my $handle = start \@args, \$in, \$out, \$err; # wait until prompted for input pump $handle until $out =~ /Login:/; $in .= "Boris\n"; # wait until prompted for password pump $handle until $out =~ /Password:/; # and so on ...