in reply to Re: Continuing While Loop One Iteration After EOF
in thread Continuing While Loop One Iteration After EOF

That will loop through the file, but then it will continue to loop forever with 'AFTERFILE' in $_. So if you're going to do that, you'd have to do it as
while (defined($_ = <INHANDLE>) || ($_ = "AFTERFILE")){ stuff; last if $_ eq "AFTERFILE"; }
and of course, if the file actually contains AFTERFILE, you're in trouble.

So if you don't mind undef as your special after loop value, it's probably easiest to do something like

LOOP: { $_ = <>; stuff; redo LOOP if defined; }

Replies are listed 'Best First'.
Re^3: Continuing While Loop One Iteration After EOF
by traveler (Parson) on Dec 22, 2005 at 17:15 UTC
    The OP suggested AFTERFILE and that's why I said "Assuming, as you imply, that the body of the loop will know what to do when it sees AFTERFILE."