Mark Knoop wrote:
> 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};

        my $value = defined $values{$id} ? $values{$id} : '<undef>';

>       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?


-- 
  ,-/-  __      _  _         $Bill Luebkert    Mailto:[EMAIL PROTECTED]
 (_/   /  )    // //       DBE Collectibles    Mailto:[EMAIL PROTECTED]
  / ) /--<  o // //      Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_</_</_    http://dbecoll.tripod.com/ (My Perl/Lakers stuff)
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to