in reply to Continuing While Loop One Iteration After EOF

Basically, you want to

  1. get a line (or undef),
  2. process the line, and
  3. loop if appropriate,

in that order. The following snippets will do just that:

{ local $_; do { $_ = <INHANDLE>; ... } while defined $_; }
for (;;) { # Loop until "last". local $_ = <INHANDLE>; ... last if not defined $_; }
{ # Loop while "redo". local $_ = <INHANDLE>; ... redo if defined $_; }
my $block = sub { ... }; &$block while <INHANDLE>; &$block foreach undef;

All of the snippets set $_ to undef on the last pass.

All of the snippets have access to the lexical variables, package variables and @_ of the parent scope.

Update: Moved local outside of the loop in first snippet.