chefchanyu has asked for the wisdom of the Perl Monks concerning the following question:
use strict; use DBI; use Data::Dumper; my $dbh = DBI->connect("dBi:mysql:cacti:localhost", "cacti", "cacti") or die("Cannot connect: $DBI::errstr\n"); my $sth = $dbh->prepare("select * from data_template_data"); $sth->execute; my $names = $sth->{NAME}; for (@$names) { printf("%-10s",$_); } print "\n"; while (my $row_ref = $sth->fetch()) { for (@$row_ref) { if (defined($_)) { printf("%-10s",$_); } # elsif ($_ eq '') # { # print 'NULL'; # } elsif (undef($_)) { print "\' \'"; } } print "\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl DBI NULL and undef
by NetWallah (Canon) on Aug 22, 2012 at 04:57 UTC | |
|
Re: Perl DBI NULL and undef
by rovf (Priest) on Aug 22, 2012 at 08:26 UTC | |
|
Re: Perl DBI NULL and undef
by mje (Curate) on Sep 03, 2012 at 15:27 UTC | |
|
Re: Perl DBI NULL and undef
by BillKSmith (Monsignor) on Aug 22, 2012 at 13:29 UTC |