Anyway I have some sparse hints you can try to speed up your code. First you are doing something like for 5 regex, for 50k lines that is very heavy approach: you are processing every line 5 times. Normally when you iterate over a file (with the slowness of filesystem) is better to do the opposite: for 50k lines, for 5 regex (even if the result of 5 * 50k and 50k * 5 is identic) and you do not really need the big array at all!
You are populating the array with a big amount of lines. This consume memory and slow your program. See reading large file where is explained that foreach my $line (<$readHandle>) {.. is list context and while (defined( my $line= <$readHandle>)) { is scalar context.
So you need a change in the loop, like
while (defined( my $ln= <$readHandle>)) { ... }
After this i see you are using if .. if .. if .. are you sure this is your intention? or better if .. elsif.. elsif .. else.. you really want to match more than one case?
Finally to speed up the loop you can insert some exit (from the loop) condition earlier in the loop. If this is possible is always worth to do.
Also if you can anchor somehow your regexes this will speed up a lot the match in long lines.
You can find these thread also interesting:
Optimising large files processing
Recommendations for efficient data reduction/substitution application
Using indexing for faster lookup in large file
HtH
L*
In reply to Re^7: Using regex with a variable
by Discipulus
in thread Using regex with a variable
by Praveen Dharmaraj
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |