|Do you know where your variables are?|
Re^3: Consumes memory then crashsby BrowserUk (Pope)
|on Mar 24, 2012 at 14:54 UTC||Need Help??|
There doesn't seem any good reason to build up your regex a bit at a time in separate variables; then concatenate those bits into another variable; and then interpolate that into a regex:
And even less reason to repeat the same 3-stage exercise over and over again each time around a loop. Especially as it means that the regex engine needs to recompile the combined regex every time around that loop even though nothing changes.
And why capture 7 different bits of the string you are matching against:
when 5 of them are constants; and you are only using one of them?
Equally, the is nothing to be gained from assigning a constant string to a variable and then interpolating it into a regex:
Cleaning up those; and a few other things up; adding strict and -w; and moving the regexing into a subroutine (to make later threading easier), I get:
Which will probably not run much more quickly as you are IO-bound, but (I hope you'll agree) is easier to read and will at least consume less cpu.
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.