Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Can't figure out how to include LAST member of the array

by jdporter (Paladin)
on Feb 09, 2021 at 20:27 UTC ( [id://11128146]=note: print w/replies, xml ) Need Help??


in reply to Can't figure out how to include LAST member of the array

How about adding a

print "M$End";
after the for loop?

That is:

for (my $i=$Start; $i <= ($End-1) ; $i++){ print "M$i --> V$i-->"; } print "M$End";

But if I were doing this, I'd probably do it like so:

for (my $i=$Start; $i <= $End; $i++) { print "M$i"; print " --> V$i-->" unless $i == $End; }

Replies are listed 'Best First'.
Re^2: Can't figure out how to include LAST member of the array
by perlynewby (Scribe) on Feb 09, 2021 at 20:59 UTC

    Thanks for the help. I did not know I could write the unless condition this way. I will try that! Thanks

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2024-04-23 16:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found