in reply to Re: Substituting '--' for Nulls
in thread Substituting '--' for Nulls

I believe the main test here needs to be for "", not for definedness. DBI is going to give him an array, and some of the values in it may be empty strings, if I understand the problem correctly. The empty strings are what needs to be replaced. I think this variation will do the job:
my @results_tmp = map {($_ ne "") ? "$_" : "--"} @results; print join(",", @results_tmp),"\n";
For those who aren't comfortable with map, this is about the same as:
my @results_tmp = @results; ($_ eq "") && ($_ = "--") for @results_tmp; print join(",", @results_tmp),"\n";

Replies are listed 'Best First'.
Re: Substituting '--' for Nulls
by Abigail-II (Bishop) on Aug 13, 2002 at 12:40 UTC
    Could you give us an example where Perl issues the warning "Use of uninitialized value" where the value is actually defined and equal to ""?

    Abigail

Re: Re: Re: Substituting '--' for Nulls
by Anonymous Monk on Aug 13, 2002 at 12:42 UTC
    The error "use of uninitialized value" described in the root node is a good indication that DBI was, in fact, properly handing back undefined values that were then being used as strings.