in reply to Convert undef to empty string in a hash
Both of GrandFather's solutions are "better" than yours because your solution violates DRY. That is, this class of coding error:$foo{$_} = $foo{$_} // '' for keys %foo;
simply cannot occur with good ol' Gramps' solutions.$Foo{$_} = $foo{$_} // '' for keys %foo; # oops I meant $foo not $F +oo
Of GrandFather's two solutions, from the perspective of DRY, this one is better:
because the name foo is mentioned only once.$_ //= '' for values %foo;
|
|---|