I am extracting data and putting it in a hash.
open FH, "$data" or die "Can't open $data: $!"; flock (FH, 1) or die "Can't lock $data for reading: $!"; foreach my $line (<FH>) { (undef,undef,undef,$email,$phone,$partners,$memberno) = split "\t", $l +ine; my @partnerssplit = split / /, $partners; $partners{$memberno} = \@partnerssplit; } close FH; print Dumper( \%partners);
$VAR1 = { 'fr065603' => [ 'fr065600' ], 'fr065601' => [ 'fr065600', 'fr065602' ], 'fr065604' => [ 'fr065600' ], 'fr065600' => [ 'fr065601', 'fr065602' ], 'fr065602' => [ 'fr065604', 'fr065603' ] };
Depending on the $level one requests, I would like to look up the values of the codes contained in the array value and extend the hash, extracting the final information as required.
The following snippet achieves the required result but doesnot extend the hash and it can be seen that extending the level would be quite complex
I'd be grateful if someone could point me in the right direction...} elsif ($level == 2) { foreach my $item (@{$partners{$base}}) { if (exists $partners{$item}) { push @allmembers1, $item, @{$partners{$item}}; foreach $item1(@allmembers1) { if (exists $partners{$item1}) { push @allmembers, $item1, @{$partners{$item1}}; } } } }
In reply to creating a hash of arrays/hashes by jonnyfolk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |