Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

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

by ikegami (Patriarch)
on Jan 23, 2022 at 17:32 UTC ( #11140745=note: print w/replies, xml ) Need Help??


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.

  • Comment on Re^2: Perl's feature to determine, in current point of loop, that this is the last one? (updated: while unpredictable)
  • Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11140745]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2022-05-20 23:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (76 votes). Check out past polls.

    Notices?