in reply to Hashing uninitialized values when no value returned from DBI sql select

You need to decide if your prog (or user) cares about the difference (in the DB) between NULL and the empty string ''.

If not, use kyle's suggestion:

$myhash{$val_1} = defined $val_2 ? $val_2 : '';

If your prog does care, you'll just have to explicitly check for definedness at each subsequent usage of the value, or use an SQL fn like ifnull(col1, val1, val2) or the local equiv, to cvt it to an unused value eg '~'.

  • Comment on Re: Hashing uninitialized values when no value returned from DBI sql select