Professional Web Applications Themes

Still getting warning for "Use of uninitialized value in join or string " (Please Help).. - PERL Beginners

I would like to know why this warning is coming back: Use of uninitialized value in join or string at line 65. #!/usr/bin/perl -w use strict; use DBI; $ENV{"ORACLE_HOME"}="/orav101/oracle/8.0.6"; [snipet] my record=( ); while( record= $sth->fetchrow_array( )) { my $recordlist = ' '; $recordlist=join(",",record); #This statement is causing the problem } exit; $dbh->disconnect;...

  1. #1

    Default Still getting warning for "Use of uninitialized value in join or string " (Please Help)..


    I would like to know why this warning is coming back:

    Use of uninitialized value in join or string at line 65.



    #!/usr/bin/perl -w
    use strict;
    use DBI;

    $ENV{"ORACLE_HOME"}="/orav101/oracle/8.0.6";

    [snipet]



    my record=( );

    while( record= $sth->fetchrow_array( ))

    {

    my $recordlist = ' ';
    $recordlist=join(",",record); #This statement is causing the problem



    } exit;

    $dbh->disconnect;



    Jason Guest

  2. #2

    Default Re: Still getting warning for "Use of uninitialized value in join or string " (Please Help)..

    On Thu, 15 Jul 2004 10:22:26 -0700 (PDT), jason corbett wrote 

    I didn't follow the original thread, but if you put:

    select nvl( column, '' )

    instead of just selecting the column, do you still get the warning?
    Perl.Org Guest

  3. #3

    Default RE: Still getting warning for "Use of uninitialized value in join or string " (Please Help)..

    jason corbett wrote: 

    [snip]
     

    Jason,

    Sorry if I wasn't clear in my earlier response to you. If there are NULL
    values in your array, you will get this warning when you try joining the
    elements of the array.

    Example:

    [edcdev:/usr2/local/cablemanager/etc 01:24 PM]$ perl -e 'use warnings;
    use strict; my array; $array[0] = "hi"; $array[3] = "hello"; my $string
    = join(",",array); print "$string\n";'
    Use of uninitialized value in join or string at -e line 1.
    Use of uninitialized value in join or string at -e line 1.
    hi,,,hello


    Your SELECT statement is returning NULL values. If this is expected and
    you still want the "join" to concatenate the other values into a string,
    then ignore the warnings. Within your while loop, throw in a "no
    warnings 'uninitialized';" to quiet that warning. See:

    perldoc warnings
    perldoc perllexwarn

    Otherwise, you'll have to clean up your SELECT statement and ensure that
    all of the fields you're looking for are populated. (add WHERE clauses
    and such)


    Hope that helps,
    - Ed
    Ed Guest

  4. #4

    Default RE: Still getting warning for "Use of uninitialized value in join or string " (Please Help)..

    I see. I guess when I use SQL Plus app. I don't get back any blank cells so I am not sure how that is happening. I'll just use the 'no warnings' and move forward. Thanks again.


    Ed Christian <ptd.net> wrote:
    jason corbett wrote: 

    [snip]
     

    Jason,

    Sorry if I wasn't clear in my earlier response to you. If there are NULL
    values in your array, you will get this warning when you try joining the
    elements of the array.

    Example:

    [edcdev:/usr2/local/cablemanager/etc 01:24 PM]$ perl -e 'use warnings;
    use strict; my array; $array[0] = "hi"; $array[3] = "hello"; my $string
    = join(",",array); print "$string\n";'
    Use of uninitialized value in join or string at -e line 1.
    Use of uninitialized value in join or string at -e line 1.
    hi,,,hello


    Your SELECT statement is returning NULL values. If this is expected and
    you still want the "join" to concatenate the other values into a string,
    then ignore the warnings. Within your while loop, throw in a "no
    warnings 'uninitialized';" to quiet that warning. See:

    perldoc warnings
    perldoc perllexwarn

    Otherwise, you'll have to clean up your SELECT statement and ensure that
    all of the fields you're looking for are populated. (add WHERE clauses
    and such)


    Hope that helps,
    - Ed

    Jason Guest

  5. #5

    Default [Solved] Still getting warning for "Use of uninitialized value in join or string " (Please Help)..

    Actually there are null values coming back periodically from the query. I wasn't aware that the table I was using with the SQL PLUS application is static inside an auxillary database (with the same name) whereas the table that the Perl script is hitting is LIVE and periodically gets updated (by the minute). So the times that I was using the SQL PLUS application, I never saw NULL values there. Sorry for the wasted time.

    JC

    "perl.org" <com> wrote:
    On Thu, 15 Jul 2004 10:22:26 -0700 (PDT), jason corbett wrote 

    I didn't follow the original thread, but if you put:

    select nvl( column, '' )

    instead of just selecting the column, do you still get the warning?

    --
    To unsubscribe, e-mail: org
    For additional commands, e-mail: org




    Jason Guest

  6. #6

    Default RE: Still getting warning for "Use of uninitialized value in join or string " (Please Help)..

    jason corbett <com> wrote:

    : I would like to know why this warning is coming back:
    :
    : Use of uninitialized value in join or string at line 65.

    There is an undefined value in record.

    print join ',', 1, 2, undef, 4;



    You can test for this with Dumper() from the Data::Dumper
    module. Look for a value of "undef" (without the quotes).

    If you find an undefined value, adjust your query to
    eliminate it or change undefined values in record to
    something else.


    use Data::Dumper 'Dumper';

    Charles Guest

  7. #7

    Default RE: Still getting warning for "Use of uninitialized value in join or string " (Please Help)..

    Thanks Charles. I am just 4months old into Perl. I am actually using th tracing DBI utility right now to see what is actually happening.

    Regards,
    JC

    "Charles K. Clarkson" <net> wrote:
    jason corbett wrote:

    : I would like to know why this warning is coming back:
    :
    : Use of uninitialized value in join or string at line 65.

    There is an undefined value in record.

    print join ',', 1, 2, undef, 4;



    You can test for this with Dumper() from the Data::Dumper
    module. Look for a value of "undef" (without the quotes).

    If you find an undefined value, adjust your query to
    eliminate it or change undefined values in record to
    something else.


    use Data::Dumper 'Dumper';

    ..
    ..
    ..

    print Dumper \record;
    next;
    my $record_list = join ',', record;


    This is called debugging. You might also read up on
    the various debugging tools that come with perl. Get used
    to these things. Debugging is as much a part of
    programming as problem solving.


    HTH,

    Charles K. Clarkson
    --
    Mobile Homes Specialist
    254 968-8328



    Jason Guest

Similar Threads

  1. Replies: 2
    Last Post: October 4th, 09:47 PM
  2. Replies: 9
    Last Post: July 14th, 04:39 PM
  3. Replies: 5
    Last Post: July 13th, 07:25 PM
  4. What is "Use of uninitialized JOIN" error?
    By Jason in forum PERL Beginners
    Replies: 4
    Last Post: July 13th, 06:00 PM

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