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