tnyflmngs has asked for the wisdom of the Perl Monks concerning the following question:
This is the offending snippet. What this does is create a hash key from the clean serial. The first value is created as an array, which is fine, but when a duplicate comes around I push it on and it adds it to the end of the first array, inside the array. What I want is:for my $row ( @{$serials}) { my $equ = $$row[$equIndex]; my $pmf = $$row[$pmfIndex]; my $pro = $$row[$proIndex]; my $serial = $$row[$serialIndex]; my $usr = $$row[$usrIndex]; my $date = $$row[$dateIndex]; my $clean = $$row[$cleanIndex]; if ($duplicates{$clean}) { push (@{$duplicates{$clean}}, [$equ, $pmf, $pro, $seri +al, $usr, $date]); } else { %duplicates = ($clean => [$equ, $pmf, $pro, $serial, $usr, + $date]); } }
so I can then print everything with an outer array length greater than 1 to a file and only get the duplicates. What I am getting isclean1 -> [[equ info] -> [equ info]] clean2 -> [equ info] clean3 -> [[equ info] -> [equ info] -> [equ info]]
I have tried pushing the values into arrays first. I tried using two arrays and pushing the values onto 1 and then push that array onto another. What I do know is that I am making this much harder than it is, but I am stumped.clean1 -> [equ info, array] clean2 -> [equ info] clean3 -> [equ info, array, array]
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: hash of arrays of arrays
by philiprbrenan (Monk) on Aug 23, 2012 at 22:50 UTC | |
|
Re: hash of arrays of arrays
by Cristoforo (Curate) on Aug 23, 2012 at 23:06 UTC | |
by tnyflmngs (Acolyte) on Aug 24, 2012 at 02:21 UTC | |
by Marshall (Canon) on Aug 24, 2012 at 11:41 UTC |