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

I get this error with my code
Use of uninitialized value in concatenation (.) at D:\begperl\build_de_sample.pl line 83.

Now that line is --- push @list3, "$id1\t$text\n";

After playing around with the code I know the problem is with $text, but I don't understand the problem b\c I declare $text.

Your wisdom is appreciated.
# *********** # CDS MVOCXX # *********** my ($sqlquery3, @list3); # PREPARE SQLQUERY3 CDS_MVOCXX********************************** $sqlquery3=$CDS->prepare(" SELECT distinct cds_mvocxx.id, cds_mvocxx.text FROM cds_mvocxx, ( SELECT cds_mspecxx.* FROM cds_mspecxx, ( SELECT prodid FROM cds_prod WHERE catid = 'AC')vt1 WHERE cds_mspecxx.prodid = vt1.prodid)vt2 WHERE id = vt2.hdrid or id = vt2.bodyid"); # RUN SQLQUERY3 CDS_MVOCXX*********************************** $sqlquery3->execute() || die "couldn't execute query: $DBI::errstr\n"; print "run\n"; while (( my $id1, my $text) = $sqlquery3->fetchrow_array) { push @list3, "$id1\t$text\n"; } # WRITE CDS_MVOCXX to a file*************************************** + open cds_mvocxx, "> c:/splitcat/components/mvocxx.txt" or die "i'm dyi +ng can't open log file"; print cds_mvocxx @list3; $sqlquery3 ->finish(); close cds_mvocxx;

Replies are listed 'Best First'.
Re: wise ones, your help is needed
by japhy (Canon) on May 02, 2001 at 20:47 UTC
      works like a charm
      while (( my $id1, my $text) = $sqlquery3->fetchrow_array) { $text = '' if not defined $text; push @list3, "$id1\t$text\n"; }
        The "more standard" (?) way of writing that would be:
        while (my ($id1, $text) = ...) { ... }
        That is, declaring both variables at the same time. It looks nicer that way, I feel.

        japhy -- Perl and Regex Hacker
      Why use negation when there is always the handy-dandy unless loop? This works as well.

      $text = '' unless defined $text;
      And it is much clearer to read (at least to me) :)

      Tiptoeing up to a Perl hacker.
      Dave AKA damian

        I didn't use "unless" there, since "if not" is the same length, and it didn't hinder comprehension. (Not to mention 'unless' becomes 'if not' at compile-time, anyway.)

        japhy -- Perl and Regex Hacker
Re: wise ones, your help is needed
by Jouke (Curate) on May 02, 2001 at 20:53 UTC
    Hi,
    In your line:
    while (( my $id1, my $text) = $sqlquery3->fetchrow_array)
    You do not check if the query indeed returns a second value for $text. You should check if the variables get values before you use them.

    hth,

    Jouke Visser, Perl 'Adept'