in reply to Perl's feature to determine, in current point of loop, that this is the last one?
Depending on what exactly you're trying to do perhaps Template::Iterator from Template Toolkit might be of inspiration (see also the TT docs).
The cake is a lie.
The cake is a lie.
The cake is a lie.
In Section
Seekers of Perl Wisdom