$coord_{$key1}{$key2}[[2]] = $sth->fetchrow_array; #### if($coord_{$key1}{$key2}[2] eq "uninitialized value") { $coord_{$key1}{$key2}[2] = 0; }