H
hymie!
Greeings.
So I've got a for loop. It's doing some printing, and at the end of
what it prints, it prints a separator line like
----------
Is there an easy way that I can tell my loop "don't print the separator
after the last iteration"?
I know I can say
print "----------" unless $i==9;
but I was hoping there might be something more robust or generic, or that
would work in a more complex loop such as
foreach $day (sort { daynum($a) <=> daynum($b) } keys %sched)
Alternately, maybe I can print the separator at the **top** of my
loop, except on the **first** iteration? I can probably do that
with a flag, but again, I was hoping for something more robust and
perl-ish.
--hymie! http://lactose.homelinux.net/~hymie (e-mail address removed)
-------------------------------------------------------------------------------
So I've got a for loop. It's doing some printing, and at the end of
what it prints, it prints a separator line like
----------
Is there an easy way that I can tell my loop "don't print the separator
after the last iteration"?
I know I can say
print "----------" unless $i==9;
but I was hoping there might be something more robust or generic, or that
would work in a more complex loop such as
foreach $day (sort { daynum($a) <=> daynum($b) } keys %sched)
Alternately, maybe I can print the separator at the **top** of my
loop, except on the **first** iteration? I can probably do that
with a flag, but again, I was hoping for something more robust and
perl-ish.
--hymie! http://lactose.homelinux.net/~hymie (e-mail address removed)
-------------------------------------------------------------------------------