Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Perl's feature to determine, in current point of loop, that this is the last one?

by jwkrahn (Abbot)
on Jan 23, 2022 at 03:52 UTC ( [id://11140737]=note: print w/replies, xml ) Need Help??


in reply to Perl's feature to determine, in current point of loop, that this is the last one?

Do you mean something like this:

$ perl -le' my @array = "A" .. "H"; my $count = @array; for my $letter ( @array ) { if ( --$count ) { print "Letter: $letter"; } else { print "Last letter: $letter"; } } ' Letter: A Letter: B Letter: C Letter: D Letter: E Letter: F Letter: G Last letter: H
  • Comment on Re: Perl's feature to determine, in current point of loop, that this is the last one?
  • Download Code

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-25 17:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found