Yes but I have a hash with 90+ elements that are "important", it's not only PF03797 like I posted in the example...
So my question, in essence is:
given my AoA, if I go through it and I discover my "important" code (like PF03797), then find the element in the AoA that is just before it in the sequence (in this case the closest one ends in position 547) and print the range from this position (548) till end end of PF03797 (which I already know of course). | [reply] [d/l] [select] |
Yes, I think I get it. Sort your array (see my other post on how to do it: Re: Stuck in my final step of code using array of arrays). Then go through the array sequentially; for each element in the array, look into your hash if the element is of specific interest, and if it is, look at the end of the previous range (you might store it in a temporary variable as you scan the array so that you don't need to go back to the previous record), get the end of the current range and print out what you need. Is this clear enough? Building on my @d sorted array given in the afore-mentioned other post, this can be something like that (still demonstrated under the Perl debugger):
DB<6> $hash{'PF03797'} =1;
DB<7> foreach $aref (@d) { print "$aref->[0]: ", $previous+1, " $are
+f->[2] \n" if exists $hash{$aref->[0]}; $previous = $aref->[2];}
Which prints:
PF03797: 548 1073
because I created the hash for value PF03797.
| [reply] [d/l] [select] |