in reply to How do I automatically feed multiple yes'es into a subroutine that waits on reads from STDIN?
You could supply an alternative definition for getStringReadFromStdin. Eg
{ no warnings 'redefine'; local *{main::get_input} = sub { "yes" }; get_answers(); } sub get_answers { print "Is this right?"; return get_input(); } sub get_input { <> }
The bare block at the top redefines get_input so that it returns 'yes', rather than input from STDIN. The redefinition is local to the block.
|
|---|