
pjshort42
Novice
Jul 19, 2012, 9:23 AM
Post #1 of 4
(1019 views)
|
|
Issues with grep
|
Can't Post
|
|
I have two arrays called nodeA and nodeB and am hoping to match them (using greb, or a better method!) to another array. The idea is that if a particular row of nodeA is in the other array (nfkbgenes) and the same row of nodeB is also in the array, we will keep the two entries. When I run it, however, the greb is only returning one of the values of the nfkbgenes in its search (it happens to be the last one, I imagine this is significant). Thank you! open FILE, "seqmonktop550.txt" or die $!; my @nfkbgenes = <FILE>; $sizenfkb = @nfkbgenes; %nfkbhash = (); %nfkbhash = map {$_ => 1} @nfkbgenes; @nfkb_nodeA = (); @nfkb_nodeB = (); @nfkb_contacts = (); $sizenodeA = @nodeA; for ($i=0; $i<$sizenfkb; $i++) { if ((defined $nfkbhash{$nodeA[$i]})and(defined $nfkbhash{$nodeB[$i]})){ print 'success'; push(@nfkb_nodeA, $nodeA[$i]); push(@nfkb_nodeB, $nodeB[$i]); push(@nfkb_contacts, $contacts[$i]);
|