L
Lance Hoffmeyer
I keep getting
Use of uninitialized value in split at ./birthday.pl line 33.
Use of uninitialized value in split at ./birthday.pl line 33.
on some of the lines of my WHILE loop. Some of the other
lines of the WHILE loop work fine.
When running the script below. I did a check outside of the
WHILE loop to see if the problem would still exist. It does
not.
#!/usr/bin/perl -w
use Pg;
use DBI;
use Date::Manip;
# Check to see if this happens outside DB loop
($year, $month, $week, $day) = split(/:/,"-0:4:3:2:0:0:0",4);
print "$year $month $week \n";
$dbh = DBI->connect ( "dbig:dbname=foobar", "foobar",
"foobar"); if ($dbh) {
print "connected\n";
my $Command = "SELECT first_name, last_name, birthday FROM gw_contact_person";
my $sth = $dbh->prepare($Command);
my $Result = $sth->execute;
$today = &UnixDate("today","%Y-%m-%d");
$date1 = ParseDate($today);
while (my @row_ary = $sth->fetchrow_array)
{
$date2 = ParseDate($row_ary[2]);
$date2 =~ s/^[0-9]{4}/2004/;
$flag = DateCalc($date1,$date2,1);
# => YY:MM:WKD:HH:MM:SS
($year, $month, $week, $day) = split(/:/,$flag,4);
if ($row_ary[2] ne ""){printf "%35s %25s %15s %15s %15s %15s %5s \n",
$row_ary[0], $row_ary[1], $row_ary[2],$date1, $date2, $flag, $year
}
$sth->finish;
$dbh->disconnect();
} else {
print "Cannot connect to Postgres server: $DBI::errstr\n";
print " db connection failed\n";
}
Use of uninitialized value in split at ./birthday.pl line 33.
Use of uninitialized value in split at ./birthday.pl line 33.
on some of the lines of my WHILE loop. Some of the other
lines of the WHILE loop work fine.
When running the script below. I did a check outside of the
WHILE loop to see if the problem would still exist. It does
not.
#!/usr/bin/perl -w
use Pg;
use DBI;
use Date::Manip;
# Check to see if this happens outside DB loop
($year, $month, $week, $day) = split(/:/,"-0:4:3:2:0:0:0",4);
print "$year $month $week \n";
$dbh = DBI->connect ( "dbig:dbname=foobar", "foobar",
"foobar"); if ($dbh) {
print "connected\n";
my $Command = "SELECT first_name, last_name, birthday FROM gw_contact_person";
my $sth = $dbh->prepare($Command);
my $Result = $sth->execute;
$today = &UnixDate("today","%Y-%m-%d");
$date1 = ParseDate($today);
while (my @row_ary = $sth->fetchrow_array)
{
$date2 = ParseDate($row_ary[2]);
$date2 =~ s/^[0-9]{4}/2004/;
$flag = DateCalc($date1,$date2,1);
# => YY:MM:WKD:HH:MM:SS
($year, $month, $week, $day) = split(/:/,$flag,4);
if ($row_ary[2] ne ""){printf "%35s %25s %15s %15s %15s %15s %5s \n",
$row_ary[0], $row_ary[1], $row_ary[2],$date1, $date2, $flag, $year
}
$sth->finish;
$dbh->disconnect();
} else {
print "Cannot connect to Postgres server: $DBI::errstr\n";
print " db connection failed\n";
}