Hi list,
I can't figure out why this simple code is failing, please help.
#!/usr/bin/perl -w
use DBI;
use strict;
use DBI qw(:sql_types);
DBI->trace( 1, 'dbitrace.log' );

my $dbh1 = DBI->connect("DBI:CSV:");
    $dbh1->{'csv_tables'}->{'table1'} = {
        'eol' => "\n",
        'sep_char' => "|",
        'quote_char' => undef,
        'escape_char' => undef,
        'file' => '/home/user/reports/report.csv',
        'col_names' => ["hostname", "url", "username", "company"]
    };
my($hostname, $url, $username, $company);
my $sel1 = $dbh1->prepare("SELECT * FROM table1");
my $sel1->execute();
while ($sel1->fetch) {
        print("Found result row: hostname = $hostname, url = $url, company = $company, 
 username = $username\n");
}
$dbh1->disconnect();
"test4.pl" 27 lines, 698 characters 

 
bash-2.03$ perl test4.pl
"my" variable $sel1 masks earlier declaration in same scope at test4.pl line 21.
Can't call method "execute" on an undefined value at test4.pl line 21.
 

 



                
---------------------------------
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!

Reply via email to