
adamjazz1
Novice
Oct 13, 2009, 8:39 PM
Post #1 of 1
(870 views)
|
Comparing two Array of hash references for identical data.
|
Can't Post
|
|
open INP, "#####.pl |"; @data=(); $nn=0; while (<INP>) { chomp; @f=split(/[ \t]+/); $trec={}; $trec->{val}=$f[1]; $trec->{fname}=$f[0]; push(@data,$trec); $nn++; } close INP; my ($new,$lastlimit,$avg,$sdev,$nnn)=&GenUtil::limCore(\@data,upper=>1,lower=>0,mult=>1.2); my %newlist; for ( my $i...$#{$new}){ $newlist{$*somekey*}=$*somevalue*; } for my $h (0 .. $#data ) { if ( exists $newlist{$*newkey*} ) { print $datakeyandval; } else { print "+".$datakeyandval; } My data being opened looks like this: {fname}->/home/###/#### {val}->-3233.3434 Genutil::Limcore takes the standard dev. of all the {val} and removes and makes a new array of hash references on numbers that are less than 1.2 times the std dev. I want to keep both sets of data, but add a "+" to the non-repeated data in $new and @data. So if $new and @data contain the same set of data, I want to do nothing, but if the data is in @data, but not new I want to add a "+" in the beginning of the new data set. So far, I think I want to loop through the unaltered @data and compare it to the $new set of data. I am not sure how to loop through @data in a way so I can compare it to $new line by line. Here is the Dumper output for: $new:{ 'fname' => '/####/4/17/###', 'val' => '-8871.348288' } And @data looks the same.
|