Thanks a lot for all of your answers. First of all the code I've posted was just some pseudo code. I didn't want you to read too much. So in my script I am not opening all the time a filehandler. Also the IO wait is very low, so it is really just the CPU which is having a lot work. It seems that I
I will have a look now at the iterators thing which looks little bit confusing to me as I am not that familiar with perl at all.