in reply to Re: Maximum sub-arrays?
in thread Maximum sub-arrays?

Everyone, thanks for your help. The problem lied in the fact that I had empty sub-arrays. I was trying to anticipate the number of unique viruses coming in. Sometimes I guess right, others not. All I needed to do was start with an array X and then push a new array on to X for each name in the database.
my @dbData; while (@names = $day->fetchrow_array()) { $name = $names[0]; push my @virus, [@dbData]; }

Replies are listed 'Best First'.
Re: Re: Maximum sub-arrays?
by Roger (Parson) on Mar 01, 2004 at 02:18 UTC
    Looking at your code:
    my @dbData; while (@names = $day->fetchrow_array()) { $name = $names[0]; push my @virus, [@dbData]; }

    Where did you initialize the values for @dbData? I suspect you wanted something like this instead:
    my @virus = (); while (my @names = $day->fetchrow_array()) { push @virus, [ $name[0] ]; }

      No, later in program (after all of the arrays have been created) the following is in a loop:
      push @{ dbData[$index] }, $somevalue;
      The  $name=$name[0] line is misleading and shouldn't have been included in my snippet.
        push @{ dbData[$index] }, $somevalue;

        Is that a typo or was that the source of your problem?

        push @{ $dbData[$index] }, $somevalue; # ^ # missing the $