Split the file into smaller chunks. You're likely eating up a lot of memory space doing nothing but shifting bits either in memory or on disk.
This is similar to how it's much faster to concatenate/replace on an array of strings rather than a single string.
The only trick of it is to make sure where you put the break in the file isn't a good match, which is relatively trivial. In fact, if you can do it by lines, that's even better, no need to check against matches.
I also find it strange that it would take PERL weeks. There is some anecdotal evidence to suggest that it can handle that in less than an hour:
In fact, they talk about 1gb files taking 2 minutes in the second link.
And I wouldn't suspect that a replacement operation should take significantly longer than a copy operation for a file, after all, it's just picking up chunks of the file and replacing some of the bits as you move them. It should be able to replace them on the fly near the speed of copying them (as they are already in memory)