in reply to managing log files

Don't worry about how to do it in Perl. Describe how you'd do in English. ("Read a line. Store it in an array. Is 'xyz' in the line?" etc.)

Once you have it in English, it's easy to translate to Perl, C++or anything else.

Note:English, in the above, is a placeholder for human language you're most comfortable writing in. 8-)