$root = { value => [ ... ]};
####
{ type => 'items', value => [ ... ]} # and other key-value pairs
{ type => 'foo', value => { ... }} # and other key-value pairs
####
sub foobar {
my $href = shift;
$href-> { value } = [ map {
foobar( $_ )
if $_-> { type } eq 'items';
$_-> { type } eq 'foo'
? SPLIT_FOO( $_ )
: $_
} @{ $href-> { value }}];
}
####
sub foobaz {
my $href = shift;
$href-> { value } = [ map {
foobar( $_ )
if $_-> { type } eq 'items';
SPLIT_IF_FOO( $_ )
} @{ $href-> { value }}];
}
####
sub fooqux {
$aref = shift;
splice @$aref, 0, @$aref, map {
fooqux( $_-> { value })
if $_-> { type } eq 'items';
SPLIT_IF_FOO( $_ )
} @$aref
}
####
sub fooquux {
$aref = shift;
for ( my $i = 0; $i < @$aref; $i ++ ) {
my $item = $aref-> [ $i ];
fooquux( $item-> { value })
if $item-> { type } eq 'items';
next unless $item-> { type } eq 'foo';
my @list = SPLIT_FOO( $item );
splice @$aref, $i, 1, @list;
$i += $#list
}
}