sub foobar { my $href = shift; $href-> { value } = [ map { foobar( $_ ) if $_-> { type } eq 'items'; $_-> { type } eq 'foo' ? SPLIT_FOO( $_ ) : $_ } @{ $href-> { value }}]; }