in reply to append return if defined else not

... write this code in [a more] professional way ...

Any consideration of 'professionalism' is likely to lead into realms of religious controversy, if not outright schism. I rush in.

I have not checked the solutions given by others, but they seem reasonable in terms of logical correctness.

However, except for the problem, already mentioned, that the code of the OP tests for truth rather than for defined-ness, which the node title suggests is the true concern of tart, I'm not sure I would change the code at all. It's a bit verbose, but it's clear enough to need no comment whatsoever.

Is the code logically correct? Does the writer clearly understand it? Will the maintainer (who may be the writer six months or a year hence) clearly understand it? If the answers to these questions are all 'yes', professionalism would seem to militate against a more terse approach which, in this case, will probably need at least one line of comment by the writer and a quick consultation of perlop by the maintainer for a precedence refresher.