in reply to Empty STDIN does not exit while loop

In general I'd recommend avoiding the pattern while(chomp(<$handle>)) because it often suffers from issues (another explanation).

You might also want to consider using a module for prompting.

use IO::Prompt 'prompt'; my $resp = prompt("Foo? ", -yn); use Term::ReadLine; my $term = Term::ReadLine->new; my $line = $term->readline("Bar? ");

Or even this (the advantage being ExtUtils::MakeMaker is a core module, even though it has a completely different purpose):

use ExtUtils::MakeMaker 'prompt'; my $value = prompt("Quz?","n");

The module does have another advantage: "If prompt() detects that it is not running interactively and there is nothing on STDIN or if the PERL_MM_USE_DEFAULT environment variable is set to true, the $default will be used without prompting. This prevents automated processes from blocking on user input."

Update 2020-11-30: See also the more powerful IO::Prompter, simple example here.