in reply to Checking string emptiness

if ( length $string ) {

I believe that length is more efficient than using a string comparison.

Naked blocks are fun! -- Randal L. Schwartz, Perl hacker

Replies are listed 'Best First'.
Re^2: Checking string emptiness
by sleet (Monk) on Apr 04, 2025 at 22:23 UTC
    It would need to be length($string // '') to avoid uninitialized value warnings.

      Not since 5.12. length undef returns undef without warning since then.