Re: adding array elements

2001-09-08 Thread Roger C Haslock
> To: "David Draley" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Friday, September 07, 2001 5:40 PM Subject: Re: adding array elements > --- David Draley <[EMAIL PROTECTED]> wrote: > > What would be the best way to add only the even array elements? > > >

Re: adding array elements

2001-09-07 Thread Curtis Poe
--- David Draley <[EMAIL PROTECTED]> wrote: > What would be the best way to add only the even array elements? > > @array[0..9]; > > #result of even elements > > thank you David, Just don't do: use strict; my @data = qw/ 1 2 3 4 5 9 /; my $sum = 0; map { $sum += $data[$_] if $

RE: adding array elements

2001-09-07 Thread Bob Showalter
> -Original Message- > From: David Draley [mailto:[EMAIL PROTECTED]] > Sent: Friday, September 07, 2001 7:18 AM > To: [EMAIL PROTECTED] > Subject: adding array elements > > > What would be the best way to add only the even array elements? > > @array[0..9];

Re: adding array elements

2001-09-07 Thread register
i can think of a few ways ... # loop through the array and check the index my $index = 1; for my $value (@array) { next if $index%2; push @only_even , $value; $index++; } # or you can shift two elements and use the last one ... for my $value (@array) { # you can a

adding array elements

2001-09-07 Thread David Draley
What would be the best way to add only the even array elements? @array[0..9]; #result of even elements thank you _ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp -- To unsubscribe, e-mail: [EMAIL PRO