For example, when the data ismy (%compdata, $comp, $file, @srcfiles); for (@data) { my ($key, $value) = split /=/; for ($key) { /component/ && do { $comp = $value; last }; /version/ && do { $compdata{$comp}{version} = $value; last }; /sourcefile/ && do { $file = $value; push (@($compdata{$comp}{$srcfiles}), $value); # <<WRONG last }; /sourcesum/ && do { $compdata{$comp}{sources}{$file} = $value }; } }
When using only the hash, the output iscomponent=HF version=NULL sourcefile=file10 sourcesum=checksum10 sourcefile=file2 sourcesum=checksum2 sourcefile=file3 sourcesum=checksum3
but I need to be able to get the same order as the provided data (by using foreach @srcfiles { get hashvalue } (which is also syntax I don't know))'sources' => { 'file3' => 'checksum3', 'file2' => 'checksum2', 'file10' => 'checksum10'
'sources' => { 'file10' => 'checksum10' 'file3' => 'checksum3', 'file2' => 'checksum2',
In reply to Re^2: how to include an array of hashes in a hash of hashes?
by anadem
in thread how to include an array of hashes in a hash of hashes?
by anadem
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |