Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^6: Stuck in my final step of code using array of arrays

by Anonymous Monk
on Mar 02, 2014 at 20:05 UTC ( [id://1076740]=note: print w/replies, xml ) Need Help??


in reply to Re^5: Stuck in my final step of code using array of arrays
in thread Stuck in my final step of code using array of arrays

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).

Replies are listed 'Best First'.
Re^7: Stuck in my final step of code using array of arrays
by Laurent_R (Canon) on Mar 02, 2014 at 21:14 UTC
    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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1076740]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2024-04-18 11:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found