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

Well, in reality, it will be
while (<INHANDLE>) { dfkahsfkasdkfjhasdklfa; dsfjasd jf; lsdfj asdljf; } continue { if (eof(INHANDLE)) { dfkahsfkasdkfjhasdklfa; dsfjasd jf; lsdfj asdljf; } }

vs

while (<INHANDLE>) { dfkahsfkasdkfjhasdklfa; dsfjasd jf; lsdfj asdljf; } dfkahsfkasdkfjhasdklfa; dsfjasd jf; lsdfj asdljf;

But that's completely misses what I meant to point out. It sounds like the OP wanted to avoid code duplication (or else, he'd would simply have used the second snippet), but your code doesn't do that.

Replies are listed 'Best First'.
Re^5: Continuing While Loop One Iteration After EOF
by davido (Cardinal) on Dec 21, 2005 at 18:25 UTC

    If avoiding code duplication is the goal, put the code that exists within the while loop into a subroutine, and call that sub one more time after the loop. If he wants to get tricky, he could generate a callback routine as a closeure within the loop that gets executed after the loop, though that seems like a lot of complexity that may lack justification.


    Dave

Re^5: Continuing While Loop One Iteration After EOF
by ruoso (Curate) on Dec 21, 2005 at 18:19 UTC

    Hmm? I agree that the "continue" solution is pointless... But is the other solution too?

    my $i = 1; while ((my $line = <INHANDLE>) || $i--) { dfkahsfkasdkfjhasdklfa; dsfjasd jf; lsdfj asdljf; }
    daniel