Hi, try changing your output structure, yes your output structure, to a much more manageable hash of hashes (of hashes of arrays). If you want to be able easily to pull out data later by group or by test, you should only use an array for the innermost values. The, um, values, haha. Anyway, you don't need all those layers of key names. If the object is of test results, you don't need to name it "test". Just get in there and index the tests. If a test hash can only have values by group, key the results by group name. It's much more natural and way easier to build. Something like this:
Then you can change{ + "root": { 1 => { "XYZ": [ "1234" ], "ABC": [ "6.13.00" ] }, 2 => { "BAB": [ "ASDAS", "12312321" ], "SADA": [ "6.13.00", "1231231" ] } ] }
topush @{ $href->{test} }, { group => $group, values => [ sort uniq $value, @{ $href->{values} // [] } ] };
Later when you reuse the data to build a report or whatever, you can give it column headers without having to store them in the data object itself.my $test_num = 0; for my $file ( @test_files ) { $test_num++; ... for my $line (<FILE>) { push @{ $href->{ $test_num }{ $group } }, $value; } }
Hope this helps!
In reply to Re: Trying to make the code more clear and clean
by 1nickt
in thread Trying to make the code more clear and clean
by ovedpo15
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |