3
임의로 큰 중첩 구조의 해시 및 배열을 스캔하고 단일 값에 대한 참조로 모든 동일한 분기 (예 : Test::Deep::cmp_deeply
이 'ok'라고 말한 모듈)를 대체 할 수있는 Perl 용 모듈을 즉시 사용할 수 있습니까?중첩 구조 내부의 동일한 분기를 참조로 신속하게 대체하는 방법은 무엇입니까?
이 문제에 대한 내 자신의 솔루션이 이미 있지만 사용할 수있는 경우 기존 빠른 XS 모듈을 사용하는 것이 좋습니다. Data::Dumper 같이 원래 구조의
예 : 예상 된 결과 구조의
$VAR1 = {
'other_elems' => [
{
'sub_elements' => [
{'id' => 333},
{
'props' => ['attr5', 'attr6'],
'id' => 444
}
],
'other_key_for_attrs' => ['attr1', 'attr5'],
'id' => 222
},
{
'sub_elements' => [{'id' => 333}],
'id' => 111
}
],
'elems' => [
{
'attrs' => ['attr1', 'attr5'],
'id' => 1
},
{
'parent' => 3,
'attrs' => ['attr1', 'attr5'],
'id' => 2
},
{
'attrs' => ['attr5', 'attr6'],
'id' => 3
},
{
'attrs' => ['attr5', 'attr6'],
'id' => 4
}
]
};
예 :
$VAR1 = {
'other_elems' => [
{
'sub_elements' => [
{'id' => 333},
{
'props' => ['attr5', 'attr6'],
'id' => 444
}
],
'other_key_for_attrs' => ['attr1', 'attr5'],
'id' => 222
},
{
'sub_elements' =>
[$VAR1->{'other_elems'}[0]{'sub_elements'}[0]],
'id' => 111
}
],
'elems' => [
{
'attrs' => $VAR1->{'other_elems'}[0]{'other_key_for_attrs'},
'id' => 1
},
{
'parent' => 3,
'attrs' => $VAR1->{'other_elems'}[0]{'other_key_for_attrs'},
'id' => 2
},
{
'attrs' =>
$VAR1->{'other_elems'}[0]{'sub_elements'}[1]{'props'},
'id' => 3
},
{
'attrs' =>
$VAR1->{'other_elems'}[0]{'sub_elements'}[1]{'props'},
'id' => 4
}
]
};