in reply to Defined vs ne ""

Your code does not compile.

Can't modify constant item in scalar assignment at test-define.pl line + 5, near ""","
This points out the problem with your code.
If you had used "strict" and "warnings", it would have told you:
Bareword "loc" not allowed while "strict subs" in use at test-define.p +l line 3.
The problem with your code is that the line should read:
loc => "", # Your code was missing the ">", in BOTH lines where y +ou declare "loc"

            "XML is like violence: if it doesn't solve your problem, use more."