or better you can do for(0.$#files) { $prev = $files[$_-1]; $next = $files[$_+1]; }
where $#files is the array's length - 1. Byeeeee On Fri, 29 Oct 2004 09:14:25 -0600, Jeff Eggen <[EMAIL PROTECTED]> wrote: > >>> "Murphy, Ged (Bolton)" <[EMAIL PROTECTED]> 29/10/2004 > 9:02:56 am >>> > >The previous item is simple to do, but I'm struggling to think of a > way of > >getting the next item. > > You could just change your foreach line to a standard for loop: > > for ( my $index = 0; $index <= $#files; $index++ ) > { > } > > And then just use $files[$index] wherever you use $_ below, and then > you can refer to as many other elements in the array as you like with > "$index + 1", "$index - 1", etc. > > Hope this helps, > > Jeff Eggen > IT Programmer Analyst > Saskatchewan Government Insurance > Ph (306) 751-1795 > email [EMAIL PROTECTED] > ************DISCLAIMER************* > This e-mail and any files transmitted with it are confidential and intended solely > for the use of the individual or entity to whom they are addressed. If you are not > the named addressee, please notify the sender immediately by e-mail if you have > received this e-mail by mistake and delete this e-mail from your system. If you are > not the intended recipient you are notified that using, disclosing, copying or > distributing the contents of this information is strictly prohibited. > ************DISCLAIMER************* > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > <http://learn.perl.org/> <http://learn.perl.org/first-response> > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>