in reply to xml - empty node

read perlintro and length

if( length $foo ){ print 1 } else { print 2 }

Replies are listed 'Best First'.
Re^2: xml - empty node
by Lotus1 (Vicar) on Apr 24, 2013 at 14:50 UTC

    length() isn't needed here since $foo is the result of $_->to_literal which returns either a string an empty string.

      length() isn't needed here

      sure it is, it clarifies intent

        Then this is even clearer. :)

        if (length $artist > 0){ print "$artist | "; } else { print "0 | "; }