in reply to Subroutine Loop

Since you have chomp $ans; try
while ($count < 5 and $ans =~ /^\s*$/)
poj