in reply to Re(2): (Ovid): uninitialized value in concatenation
in thread uninitialized value in concatenation

This code is not working because the sql is returning a '' value and the if statement is seeing it as being true. what can I change so it evaluates the '' as no value returned.
# store subparent for each parent my %parent_hash = ( 'Father' => 'Mother', 'Mother' => 'Father' ); if (exists $parent_hash{$parent}) { my $sub_parent = $parent_hash{$parent}; for my $col ( $parent, $sub_parent ) { my $sql = "select $col from Roster where User=?"; my $rv = $dbh->selectcol_arrayref( $sql, undef, $user); if ( @$rv) { # any rows returned? $name = $rv->[0]; # take first one last; } } }

Replies are listed 'Best First'.
Re: (4): (Ovid): uninitialized value in concatenation
by dmmiller2k (Chaplain) on Jan 15, 2002 at 20:17 UTC

    "... the sql is returning a '' value and the if statement is seeing it as being true."

    This is not correct.

    As written, the if statement is not testing for truth or falseness, but whether or not any rows were returned.

    To accomplish what you seek, change the if statement to read:

    if ( @$rv && $rv->[0] ) { # any NON-BLANK rows returned?

    dmm