Re: foreach loop current index

2005-05-21 Thread John Doe
Am Samstag, 21. Mai 2005 04.21 schrieb Peter Rabbitson: > Hello, > > When perl executes a foreach loop, it creates some kind of array of all the > iterators and then goes over them one by one. Is the current index pointer > accessible from inside the loop? I was unable to find anything related in >

Re: assigning printf statement to an array

2005-05-21 Thread Offer Kaye
On 5/21/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Here is my code, but I am not seeing the elements being populated as I say > show me the data in element 1 > Line 28 is not working after executing line 30. > Any ideas? > You probably want to use "sprintf" instead of "printf". Read "

Re: undefined...

2005-05-21 Thread Offer Kaye
On 5/21/05, Ley, Chung wrote: > Hi, > > I have a piece of code which generates array of arrays which then is used to > call the > GD::Graph::Boxplot... > > For some reasons, I would have elements that is defined but has not value. I > have been > going thru the code to see if I had accidenta

Re: foreach loop current index

2005-05-21 Thread Paul Johnson
On Fri, May 20, 2005 at 09:21:04PM -0500, Peter Rabbitson wrote: > When perl executes a foreach loop, it creates some kind of array of all the > iterators and then goes over them one by one. Is the current index pointer > accessible from inside the loop? I was unable to find anything related in

Re: foreach loop current index

2005-05-21 Thread Offer Kaye
On 5/21/05, Peter Rabbitson wrote: > Hello, > > When perl executes a foreach loop, it creates some kind of array of all the > iterators I'm assuming you mean that this code: foreach my $num (1..1_000_000) { do_something($num); } creates a one-million number array? No, it doesn't, at least not

RE: foreach loop current index

2005-05-21 Thread Charles K. Clarkson
Offer Kaye wrote: : : Neither was I, but I suspect the reason is that if you need a : counter, you should not be using "foreach". Instead, use "for": : for(my $counter = 0; $counter < @array; ++$counter) { : do_something_with($array[$counter]); : } Why is that for

Re: foreach loop current index

2005-05-21 Thread JupiterHost.Net
: Neither was I, but I suspect the reason is that if you need a : counter, you should not be using "foreach". Instead, use "for": : for(my $counter = 0; $counter < @array; ++$counter) { : do_something_with($array[$counter]); : } Why is that form favored over this typical foreach form? fore

Re: foreach loop current index

2005-05-21 Thread Peter Rabbitson
> The reason this has not been built into the language is that there would > be an overhead associated with each loop to maintain this variable. The > Perl5 team felt that this was not acceptable given that most loops do > not need this information and, and you have noted, it's trivial to do > the

RE: undefined...

2005-05-21 Thread Ley, Chung
Hi, Sorry, it is my bad with the explanation... Basically, I am using the GD::Graph::Boxplot for creating a boxplot... To do that, I need to pass in an array of arrays. My problem is that it generates the graph but with a lot of warnings about "uninitialized" values that is in the boxplot.pm