--- nfo/perl/libs/Data/Mungle/Transform/Deep.pm 2003/05/10 17:09:18 1.22 +++ nfo/perl/libs/Data/Mungle/Transform/Deep.pm 2003/05/13 07:39:22 1.23 @@ -1,7 +1,10 @@ ## --------------------------------------------------------------------------- -## $Id: Deep.pm,v 1.22 2003/05/10 17:09:18 jonen Exp $ +## $Id: Deep.pm,v 1.23 2003/05/13 07:39:22 joko Exp $ ## --------------------------------------------------------------------------- ## $Log: Deep.pm,v $ +## Revision 1.23 2003/05/13 07:39:22 joko +## new option 'define' for "sub expand": set value to empty string if desired +## ## Revision 1.22 2003/05/10 17:09:18 jonen ## + added keep of empty arrays/hashes if 'expand' for php ## @@ -169,6 +172,7 @@ # convert values in hash to utf8 (and back) to be ready for (e.g.) encapsulation in XML # but still using the known latin locale stuff +# TODO: Review: Could this be revamped using Clone.pm? sub expand { my $obj = shift; @@ -207,6 +211,8 @@ $item = latin_to_utf8_scalar($item) if ($item && $options->{utf8}); $item = utf8_to_latin_scalar($item) if ($item && $options->{to_latin}); } + + $item = '' if $options->{define} and not defined $item; #push(@{$result}, $item) if $item; # use item only if not undef (TODO: make configurable via $options) push(@{$result}, $item); # use item in any case @@ -250,6 +256,8 @@ $item = latin_to_utf8_scalar($item) if ($item && $options->{utf8}); $item = utf8_to_latin_scalar($item) if ($item && $options->{to_latin}); } + + $item = '' if $options->{define} and not defined $item; #$result->{$_[0]} = $item if $item; # use item only if not undef (TODO: make configurable via $options) $result->{$_[0]} = $item; # use item in any case }