How about a QND null-value fixer-upper? Something like...
foreach my $id (sort keys %values) {
my $value = $values{$id} || 'OOPSIE! Null value encountered!';
print <<EOF;
some stuff
$value
some more stuff
EOF
}
Would that help?
D.
| "Mark Knoop" <[EMAIL PROTECTED]>
Sent by: [EMAIL PROTECTED] 11/01/2005 12:05
|
To: <[email protected]> cc: Subject: Warnings, fetchrow and uninitialized values. |
Hi there
After taking on board the advice of some the guys here I have started using
'use warnings' as a matter of course.
I am retrieving fields from a db using the following principle
...
my %values;
while (my ($id, $value) = $sth->fetchrow) {
$values{$id} = $value;
}
...
to get all the fields first and then
...
foreach my $id (sort keys %values) {
my $value = $values{$id};
print <<EOF;
some stuff
$value
some more stuff
EOF
}
In practice there are lots of values and extra bumf in the string concat
hence moving the value from hash to scalar for clarity plus it seems to
process a lot quicker than mixing up the query and the printing.
Problem is that if the value in the database is NULL then I get a warning
saying 'Use of uninitialized value in concatenation (.) or string at line
<wherever the print EOF is>'
Any thoughts on the neatest way of handling this?
Cheers
Mark
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________ ActivePerl mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
