SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Mar 2009
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Please help: Use of uninitialized value in concatenation (.) or string

    Hi there, this is my first perl program, I really appreciate if someone could help me with what's wrong here:

    I could see on screen the print out results seem to be correct.
    However I keep on getting the message saying "Use of uninitialized value in concatenation (.) or string " for the line stating "print "$sec\t $tlnk\t $ratio \n";

    I have assigned value to $sec, $tlnk and $ratio, why I am seeing these errors? Many thanks!

    The codes are:

    $sth = $dbh->prepare ("select count(*) from...");
    $sth->execute;
    if ($sth->rows == 0) {
    die "No rows!\n";
    } else {
    if ($firstResult = $sth->fetchrow) {
    print $firstResult
    };
    };


    $sth->finish();

    $sth = $dbh->prepare (
    "select sec, tlnk from ... ");

    $sth->execute;
    if ($sth->rows == 0) {
    die "No rows!\n";
    } else {
    while (my @data = $sth->fetchrow_array()) {
    my $sec=$data[0];
    my $tlnk=$data[1];
    my $ratio=$sec/$firstResult;
    print "$sec\t $tlnk\t $ratio \n";


    };

  2. #2
    SitePoint Wizard bronze trophy KevinR's Avatar
    Join Date
    Nov 2004
    Location
    Moon Base Alpha
    Posts
    1,053
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Unfortunately we can't see the output, we don't know the input. The reason you get that warning is that one of the scalars in this line:

    print "$sec\t $tlnk\t $ratio \n";

    has no value. But there is no way for us to know why. You need to add more "print" lines to the data and watch it as it runs and see if you can spot when/where the uninitialzed value occurs.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •