--
Brian Raven

> -----Original Message-----
> From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-
> win32-users-boun...@listserv.activestate.com] On Behalf Of Barry Brevik
> Sent: 04 November 2011 23:56
> To: perl Win32-users
> Subject: Help with error msg
>
> I've been programming Perl for quite a while, but I've just recently
> started to 'use strict' because, well it seems like the right thing to
> do.

It almost always is. Keep it up.

>
> However, I'm getting this runtime error: "Use of uninitialized value in
> join or string at test56.pl line 40." Line 40 is the one where the same
> message is in the comment.

I think that is a warning rather than an error, i.e. nothing to do with 'use 
strict'. 'use warnings' is good for you, and your code, as well.

>
> I realize that the sample code has some elements specific to my
> environment, but it is the best I could do, and it is pared down quite
> a
> bit.
>
> Thanks,
> Barry Brevik
> ----------------------------------
> use strict;
> use warnings;
> use Win32::ODBC;
> use Win32::Console;
>
> # Un-buffer STDOUT.
> select((select(STDOUT), $| = 1)[0]);
>
> # Set up a DSN-less connection.
> my $connectStr = "DRIVER=Microsoft ODBC for Oracle; SERVER=prod;
> UID=APPS; PWD=apps";
>
> my $SQLsentence = <<SQL;
> select
>   fa.asset_number
> , fa.asset_description
> , fa.manufacturer_name
> , fa.serial_number
> , fa.owned_leased
> , fa.new_used
> , fa.category_description
>
> from
>   fafg_assets fa
>
> order by
>   fa.category_description, fa.asset_description
> SQL
>
> getOutFile();
>
> if (my $db = new Win32::ODBC($connectStr))
> {
>   # Execute our SQL sentence.
>   unless ($db -> Sql($SQLsentence))
>   {
>     # Loop through the table.
>     while (scalar $db -> FetchRow(1, SQL_FETCH_NEXT))
>     {
>       my @data = $db -> Data();
>
>       print OUTFILE '"', (join '","', @data), '"', "\n";
>     }
>   }
>
>   $db -> Close();
> }
>
> #------------------------------------------------
> sub getOutFile
> {
>   my $filename = "c:\\temp\\asset.csv";
>
>   if (open OUTFILE, '>', $filename)
>   {
>     print "  Output file $filename has been CREATED.\n\n";
>   }
> }

I can't accurately identify the line from your description, but the join 
statement seems a likely candidate. If so, it looks like your call to 
$db->Data() is returning one or more undef values, probably from a null field 
in your database. To avoid such warning you need to check for undefs. If you 
just want to replace them with something printable, then something like this 
could do the trick...

my @data = map {$_ ||= "NULL"} $db -> Data();

HTH



Please consider the environment before printing this e-mail.

This e-mail may contain confidential and/or privileged information. If you are 
not the intended recipient or have received this e-mail in error, please advise 
the sender immediately by reply e-mail and delete this message and any 
attachments without retaining a copy.

Any unauthorised copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to