RE: Array Size Question(s)

2001-05-14 Thread Paul
--- Peter Cornelius <[EMAIL PROTECTED]> wrote: > A cool control structure in perl is the for or foreac loop. With it > you don't need to know the size of the array you can just >for my $thing (@A) { > #do stuff with $thing >} This is very efficient; just keep in mind that $thing i

Re: Array Size Question(s)

2001-05-14 Thread Paul
--- Collin Rogowski <[EMAIL PROTECTED]> wrote: > You get the size of an array by using it in a scalar context. > $size = @a; This is entirely correct. But for those of you who prefer a more explicit syntax, you can put any expression into scalar context with the "scalar" keyword. For my own tast

RE: Array Size Question(s)

2001-05-14 Thread Peter Cornelius
A cool control structure in perl is the for or foreac loop. With it you don't need to know the size of the array you can just for my $thing (@A) { #do stuff with $thing } If you're familiar with shell syntax this is kinda like the 'for i in list' construct. Books - You might check

Re: Array Size Question(s)

2001-05-14 Thread Collin Rogowski
First part: You get the size of an array by using it in a scalar context. Sounds complicated? Scalar context means that the left side of an assignment is a scalar. So you just write: $size = @a; and you get the size of the array @a. Another method would be to get the index of the last element a

Re: Array Size Question(s)

2001-05-14 Thread Paul Cotter
while($ansNum < $numOfAns) where $ansNum starts at zero and is incremented until it is at $numOfAns(from the split line above, it's value should represent the number of elements in @A). This all works, but I would like to improve it and make it so that the user making the text file doesn't have t