if (exists $main_target->{target}->{sub_target}) #### if (exists $main_target->{$target}->{sub_target}) # ^