http://www.perlmonks.org?node_id=11140745


in reply to Re: Perl's feature to determine, in current point of loop, that this is the last one? (updated: while unpredictable)
in thread Perl's feature to determine, in current point of loop, that this is the last one?

It can't be solved generically for while loops.

while (@a) { shift(@a); if ( is_last_pass() ) { push @a, "foo"; } }

But, you can "peek ahead" sometimes.