Re: understanding adding numeric accumulator

2011-07-10 Thread Chris Nehren
Chris, your quoting mechanism is extremely unclear. It's difficult to discern what you wrote and what the people you're quoting wrote. On Fri, Jul 08, 2011 at 20:05:14 -0400 , Chris Charley wrote: > Hello JJ, > > It is sometimes helpful to put print statements in a routine to > follow the flow of

Re: understanding adding numeric accumulator

2011-07-08 Thread Chris Charley
""J. S. John"" wrote in message news:caahf0rkhyip680xk9kz+3q4uvw79s2dh8denulob_2gxlyf...@mail.gmail.com... Hi all, I'm teaching myself perl. Right now, I am stuck with this script. I don't understand how it works. I know what it does and how to do it by hand. $n = 1; while ($n < 10) { $s

Re: understanding adding numeric accumulator

2011-07-08 Thread Rob Coops
On Sat, Jul 9, 2011 at 1:33 AM, J. S. John wrote: > Hi all, > I'm teaching myself perl. Right now, I am stuck with this script. I > don't understand how it works. I know what it does and how to do it by > hand. > > $n = 1; > while ($n < 10) { >$sum += $n; >$n += 2; > } > print "The sum is

Re: understanding adding numeric accumulator

2011-07-08 Thread Jim Gibson
On 7/8/11 Fri Jul 8, 2011 4:33 PM, "J. S. John" scribbled: > Hi all, > I'm teaching myself perl. Right now, I am stuck with this script. I > don't understand how it works. I know what it does and how to do it by > hand. > > $n = 1; > while ($n < 10) { > $sum += $n; > $n += 2; > } > pri

understanding adding numeric accumulator

2011-07-08 Thread J. S. John
Hi all, I'm teaching myself perl. Right now, I am stuck with this script. I don't understand how it works. I know what it does and how to do it by hand. $n = 1; while ($n < 10) { $sum += $n; $n += 2; } print "The sum is $sum.\n" I know $sum is initially 0 (undef). I see that $sum becomes