Professional Web Applications Themes

What is "Use of uninitialized JOIN" error? - PERL Beginners

Can anyone tell me what is happening here? Thanks, JC Here is the part of the code that the error is pointing to print OUTFILE "$recordlist\n"; $recordlist=join(",",record);...

  1. #1

    Default What is "Use of uninitialized JOIN" error?

    Can anyone tell me what is happening here?

    Thanks,
    JC

    Here is the part of the code that the error is pointing to

    print OUTFILE "$recordlist\n";
    $recordlist=join(",",record);


    Jason Guest

  2. #2

    Default RE: What is "Use of uninitialized JOIN" error?

    Hard to tell for certain from that snippet, but I'd say record is a null value in your execution for one reason or another (i.e. there is nothing stored in that array) so when it tries to execute the join, there is no list for the second argument to the "join" function.

    In handling it, you need to decide if that is a legitimate execution (i.e. is it ok that record is empty) or if it is the result of an error in another part of your code.

    Jonah Jackson

    -----Original Message-----
    From: jason corbett [mailto:com]
    Sent: Tuesday, July 13, 2004 10:47 AM
    To: perl beginners
    Subject: What is "Use of uninitialized JOIN" error?


    Can anyone tell me what is happening here?

    Thanks,
    JC

    Here is the part of the code that the error is pointing to

    print OUTFILE "$recordlist\n";
    $recordlist=join(",",record);

    Jonah Guest

  3. #3

    Default Re: What is "Use of uninitialized JOIN" error?

    On Jul 13, jason corbett said:
     

    It's not an error, it's a warning. And you didn't give us the *actual*
    text of the warning. It looks to me like the problem is you're using the
    variable before you've given it a value!

    my $recordlist = join ",", record;
    print OUTFILE "$recordlist\n";

    --
    Jeff "japhy" Pinyan % How can we ever be the sold short or
    RPI Acacia Brother #734 % the cheated, we who for every service
    http://japhy.perlmonk.org/ % have long ago been overpaid?
    http://www.perlmonks.org/ % -- Meister Eckhart

    Jeff Guest

  4. #4

    Default Re: What is "Use of uninitialized JOIN" error?





    Where do you populate record? Such messages occur when populating an
    array with contents of a file (if the file contains a bunch of newlines).
    So make sure you know what the array is getting populated with by testing.


    Also, you want to join before printing, correct? So swap the lines (but
    that is not the cause of the warning).
     

    I will try to view the contents of record with
    foreach my $item (record) {
    print " ..... item: $item\n";
    }




    __________________

    William Ampeh (x3939)
    Federal Reserve Board

    William Guest

  5. #5

    Default [The Subroutine] What is "Use of uninitialized JOIN" error?

    Thanks all for the feedback on the WARNING message that I am getting. I know that I can turn warning off at that moment of code, but I want to know for my own knowledge what is the warning all about. So, here is the entire sub routine. NOTE** I declared records as a global earlier..

    JC

    sub data_collect {unless (open(OUTFILE,">$fourdayreport"))

    {die open(ERRORLOG, ">>$errorlog") &&

    print ERRORLOG "Sorry file $dayreport couldn't be created\n"; return "Failed";}

    else{

    while( record = $sth->fetchrow_array() )
    {
    # no warnings;

    my $recordlist=join(",",record);

    print OUTFILE "$recordlist\n";

    }return "success";

    }
    }
    gov wrote:




    Where do you populate record? Such messages occur when populating an
    array with contents of a file (if the file contains a bunch of newlines).
    So make sure you know what the array is getting populated with by testing.


    Also, you want to join before printing, correct? So swap the lines (but
    that is not the cause of the warning).
     

    I will try to view the contents of record with
    foreach my $item (record) {
    print " ..... item: $item\n";
    }




    __________________

    William Ampeh (x3939)
    Federal Reserve Board


    Jason Guest

Similar Threads

  1. Replies: 2
    Last Post: October 4th, 09:47 PM
  2. Replies: 2
    Last Post: February 19th, 11:17 AM
  3. #12029 [Com]: "--with-apxs" can cause the error "MySQL: Unable to save result set in"
    By sietzepost at streetwisedd dot nl in forum PHP Development
    Replies: 1
    Last Post: October 3rd, 09:21 AM

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139