in reply to Seek and Find

Load the values of your first file into a hash rather than an array, lookup will be easier and performance much faster.

Then read the second file and check if the values can be found in the hash.

Provide some sample data if you need more help.

Replies are listed 'Best First'.
Re^2: Seek and Find
by hbrown.bios (Initiate) on Feb 08, 2016 at 19:07 UTC
    So here is an example of some of may data: GLU 66 PRO 436 9.116044197 Blank Asterisk GLU 67 ASN 427 9.34269896 Asterisk Asterisk What I would like it to do is if column 2 matches a number in the hash (or array), and the value in column 4 is within a given range of numbers, and column 7 matches a search phrase such as "Asterisk" it would print the entire matching line to a new file, and then for it to continue searching until the end of the document.
        here is the code I have so far:
        #!/usr/bin/perl @cand (63, 66, 69, 72, 73, 74, 95, 96, 98, 134, 135, 137, 138, 139, 14 +0, 159, 162, 172, 173, 175, 177, 178, 197, 198, 201, 210, 225, 232, 2 +37, 240, 243, 246, 247); open (<CONTACT0>, "Contactmap00_0.txt"); while (<CONTACT0>) { foreach $c (@cand){ foreach $_ { @line = split (//, $_); if $c = $line[2] { if $line[4] >= 133 { if $line[4] <= 298 { if $line[6] != ['Asterisk' 'Colon']{ print $_ "\n"; } else print "Mismatch at level Type \n";} else print "Too large for range\n";} else print "To small for range \n";} else print "Not a match to candidates\n";} } }
        My data looks like this
        ILE 105 GLY 404 9.31639356 Blank Asterisk ILE 105 VAL 430 7.716578207 Blank Colon GLY 106 SER 429 9.615782075 Asterisk Asterisk GLY 106 VAL 430 6.799878306 Asterisk Colon GLY 106 LEU 433 8.984377971 Asterisk Colon GLY 106 SER 434 9.609582172 Asterisk Asterisk GLY 107 SER 428 8.263658329 Asterisk Asterisk GLY 107 SER 429 6.30787898 Asterisk Asterisk GLY 107 VAL 430 4.124362412 Asterisk Colon GLY 107 LEU 431 7.670615378 Asterisk Asterisk GLY 107 ALA 432 8.308317297 Asterisk Period GLY 107 LEU 433 5.934571065 Asterisk Colon GLY 107 SER 434 7.71234967 Asterisk Asterisk LYS 108 ASN 427 8.67223833 Blank Asterisk LYS 108 SER 428 5.458321198 Blank Asterisk