in reply to $_ unitialized

Why doesn't <STDIN> initialize and fill $_ in the following control block?

Because <STDIN> never changes $_.

while (<$fh>) { ... }
is short for
while (defined($_ = <$fh>)) { ... }
But since you don't have something of the form
while (<$fh>) { ... }
you never assign anything to $_.
while (<STDIN>) { s/\s+$//; last if /^(?:exit|quit)?$/i; ... }