length() isn't needed here since $foo is the result of $_->to_literal which returns either a string an empty string.
In reply to Re^2: xml - empty node by Lotus1 in thread xml - empty node by ambrill