On Tue, Oct 21, 2008 at 09:39, six24hourdays <[EMAIL PROTECTED]> wrote: > Hello, > > I would like to know how to test for the last element of a list during > a foreach loop, e.g. > > foreach $element (@List) { > if (this is the last element) { > do something > } > } > > What would I use for the IF condition? snip
This is an odd desire; are you sure you really need to do this? Can you tell us what you are trying to achieve? Jeff's answer does what you want, but most likely there is a better approach to be using for your actual problem. -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/