Discussion:
Still getting warning for "Use of uninitialized value in join or string " (Please Help)..
(too old to reply)
Jason Corbett
2004-07-15 17:22:26 UTC
Permalink
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;
Perl.Org
2004-07-15 17:25:58 UTC
Permalink
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?
Jason Corbett
2004-07-15 17:52:10 UTC
Permalink
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
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: beginners-***@perl.org
For additional commands, e-mail: beginners-***@perl.org
Ed Christian
2004-07-15 17:32:04 UTC
Permalink
Post by Jason Corbett
Use of uninitialized value in join or string at line 65.
[snip]
Post by Jason Corbett
{
my $recordlist = ' ';
} exit;
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:

[***@dev:/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 Corbett
2004-07-15 17:39:53 UTC
Permalink
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.
Use of uninitialized value in join or string at line 65.
[snip]
{
my $recordlist = ' ';
} exit;
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:

[***@dev:/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
Charles K. Clarkson
2004-07-15 18:33:36 UTC
Permalink
jason corbett <***@yahoo.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';

.
.
.

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 Corbett
2004-07-15 19:00:57 UTC
Permalink
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" <***@htcomp.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
Loading...