As Perlbotics points out, you are actually getting $reply twice, once on (non-blank) line 7, and then again on (non-blank) line 12. The $reply on line 7 is discarded. If you give a satisfactory reply on line 12, then the while loop doesn't actually run at all, as you would expect; you can tell this by noting that the or else! warning never appears.