in reply to parsing long text file

For starters you need not include all variables inside your loop as you are reinitializing everything every single time you go through the loop. Also do you can probably replace all the lines of: if (m/<whatever>/g){...} with just (m/<whatever>/) or just (/whatever/) as it seems you are just checking to see if something exists in a line, and there is no need to check further after that point.