Hello all, 

testing the use of DBI. Having a problem (highlighted in red) with using
"@$_" as the topic. When I use @row the program writes records as
expected to test.txt but when I use the topic it only writes ...

""

""

""

in the file.  I have reread documentation to see if I am using @$_
correctly and it seems OK to me can anyone help ?

 

thanks,

 

 

Duan.

 

 

Source code ....

 

use warnings;

use strict;

 

use DBI;

use Data::Dumper; 

 

 

my $destination = "test.txt";

my $dbh = DBI->connect( "dbi:ODBC:Northwind", "", "",

    {RaiseError => 1, PrintError => 1, AutoCommit => 1} ) or

die "Unable to connect: " . $DBI::errstr . "\n"; 

 

open OUTPUT, ">$destination" or die $!;

 

# OK, connected, now select from Customers table. 

 

my $sel = $dbh->prepare( "select CustomerID,CompanyName,Country from
Customers where CustomerID like ?" ); 

 

$sel->execute( qq{%} );

 

if ($ARGV[0]) {

            while ($sel->fetchrow_array) {

                        print OUTPUT '"';

                        print OUTPUT join '","', map {$_||0} @$_;

                        print OUTPUT '"',"\n";

            }

}

else {

            while (my @row = $sel->fetchrow_array) {

                        print OUTPUT '"';

                        print OUTPUT join '","', map {$_||0} @row;

                        print OUTPUT '"',"\n";

            }

}


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>

Reply via email to