in reply to complaint: always testing defined()

That's what subroutines are for.
sub is_empty_string { my ($value) = @_; defined $value and $value eq ''; } if (is_empty_string $params->{root} ) { }

Replies are listed 'Best First'.
Re^2: complaint: always testing defined()
by roman (Monk) on Nov 03, 2007 at 22:02 UTC

    I would advice against using and in this context, because later someone (you) may add an innocent return ....

    sub is_empty_string { my ($value) = @_; return defined $value and $value eq ''; }

    I think && is more appropriate here:

    sub is_empty_string { my ($value) = @_; return defined($value) && $value eq ''; }