xspikx has asked for the wisdom of the Perl Monks concerning the following question:

Hi there,
It looks like I'm running into some weird issue that is causing me some problems. I have written a report script that uses DB connection to retreive data based on which it creates the report. I had run it on my computer and works fine, however when I put it up on a server, it does not fully work. Both use perl 5.8.1. Now I did run a debug (use diagnostics;) that returns me the following:

Use of uninitialized value in concatenation (.) or string at ./class_report_final.pl line 92
The line looks like this:
push(@MASTER, row[0].":".$row[1].":$matrix[$ab][3]:".$total_packages." +:AI"); last SWITCH; }

I can't figure it out what is wrong. Can you help.
Thanks

20040818 Janitored by Corion: Added formatting, changed title from "Confused"

Replies are listed 'Best First'.
Re: Confused about "unitialized value" warning
by davorg (Chancellor) on Aug 18, 2004 at 16:05 UTC

    Basically, it means that one of the variables that you use in that line contains no data. But as to which of them it is, we'd need to see more of the code.

    Try printing them all out, one at a time, before that line.

    --
    <http://www.dave.org.uk>

    "The first rule of Perl club is you do not talk about Perl club."
    -- Chip Salzenberg

      This is where I create my "matrix" variable. I presume this is where the problem comes from:

      while( my @row1 = $query1->fetchrow_array()) { push(@matrix, [@row1]); $count ++; }

      Then I have a while loop

      $ab=0; while ( $ab < $count) { if ( $matrix[$ab][0] == $row[2]) { if (1000 <= $total_packages) { push(@MASTER, $row[0].":".$row[1].":$matrix[$ab][3]:".$tot +al_packages.":AI"); last SWITCH; } } $ab ++; }

      20040818 Janitored by Corion: Added formatting

        You code isn't exactly easy to follow (we have <code> tags you know), but is it possible that some of the data you get back from DBI can contain NULLs? There would translate to Perl "undef" values.

        --
        <http://www.dave.org.uk>

        "The first rule of Perl club is you do not talk about Perl club."
        -- Chip Salzenberg

Re: Confused about "unitialized value" warning
by Grygonos (Chaplain) on Aug 18, 2004 at 16:09 UTC

    maybe a type, but row[0] should be $row[0] no?

      But that wouldn't cause the error.

      --
      <http://www.dave.org.uk>

      "The first rule of Perl club is you do not talk about Perl club."
      -- Chip Salzenberg

        There shouldn't be any NULL returned form the DB. The data that I'm pulling from the DB into this array (matrix) does contain information (usernames, names, addresses). For some reason it looks like perl is not able to properly identify my $matrix$ab[0] variable (which should be a username). What makes me wonder even more is that it works on one machine but not on the server itself, even though they run the same version of Perl. Could there be any missing modules or something?
Re: Confused about "unitialized value" warning
by ikegami (Patriarch) on Aug 18, 2004 at 16:55 UTC

    Start by finding out which var is undefined, then keep backtracking.

    print STDERR ('$row[0]: ', defined($row[0])?1:0, "\n"); print STDERR ('$row[1]: ', defined($row[1])?1:0, "\n"); print STDERR ('$matrix[$ab]: ', defined($matrix[$ab])?1:0, "\n"); print STDERR ('$matrix[$ab][3]: ', defined($matrix[$ab][3])?1:0,"\n"); print STDERR ('$total_packages: ', defined($total_packages)?1:0,"\n"); push(@MASTER, $row[0].":".$row[1].":$matrix[$ab][3]:".$total_packages. +"AI"); last SWITCH; }

    (row[0] should be $row[0])

      It looks like i have to play with my variable. Since it is a multi dimensional array, in some lines I tried using ${matrix}[$ab][0] and on others @{matrix}[$ab][0] and it seems like it starts to work
        You shouldn't have to use '@' there. It's very confusing to read, at the very least.