Thanks graff the code takes around :-
4115 wallclock secs (4112.37 usr + 0.28 sys = 4112.65 CPU)
for running one methylome file that is similar to file2 in the above comments.

I have been programming for quite some time but I have mostly used cookbook solutions to make things work and that seem to have stunted my learning in perl or programming as a whole of solutions like indexing. What would be a good way to learn such tricks as indexing e.t.c. Thanks again for all your help