in reply to How can I keep the values in the array?

First guess at a quick glance: This is a scoping problem, try

#---- snip --- my @allrows; my @UDNumber; while (my @row1 = $sth ->fetchrow_array){ print "@row1\n"; # prints the current row @allrows = (@allrows,@row1); @IDnumber=@row1; } # allrows contains everything now # IDNumber contains the last row
@row1 in your code is only valid inside the loop-body, always use strict; and use warnings to fight scoping errors and "code better(tm)" ;-)

regards,
tomte


Hlade's Law:

If you have a difficult task, give it to a lazy person --
they will find an easier way to do it.

Replies are listed 'Best First'.
Re: Re: How can I keep the values in the array?
by luoina (Acolyte) on Mar 03, 2004 at 19:41 UTC
    Thank you so much! It works!!! Young

      It may work, but it also copies the @allrows array again and again for each loop iteration. This is probably a Bad Thing (tm). I would suggest using push to add new items to the end of an existing array. I would also suggest checking out Limbic~Region's reply. His code actually creates an array of arrays, which may preserve the original structure of the data more accurately.