Hi Dave,
I stripped out a lot of the code to produce a test harness for you and magically the problem went away (i removed several DBI calls and several similar functions). Going back to my original source code; I have several similar bits of code and if i make the same changes as detailed in my original post it causes other regex to fail in peculiar ways.
I don't know how to proceed with this, I think it's something to do with memory or the passing of references. Unfortunately I cannot provide you with my original source code as I suspect my employer would not be keen on this :)
Thanks for your help
Cheers
Gordon