in reply to perl code to automate launching a program and entering responses

Most Unix systems have a little program called "yes"1, which simply repeatedly outputs a string (by default "y\n") in order to answer questions like the one you mentioned. With that, the task essentially becomes a piped open:

#!/usr/bin/perl -l # foo.pl print "Hello world. Should I continue? (y/n)"; my $answer = <STDIN>; print "Ok, you said $answer";
#!/usr/bin/perl open my $foo, "yes | ./foo.pl |" or die $!; while (<$foo>) { print ": $_"; }
$ ./876596.pl : Hello world. Should I continue? (y/n) : Ok, you said y :

___

1 if you don't have it, you can trivially write it yourself...

Update:

Of course, if you want to actually read the questions (and only respond with 'y' to "Hello world. Should I continue?", instead of every question), you'd have to set up bidirectional communication, e.g. using IPC::Open3.