xorl has asked for the wisdom of the Perl Monks concerning the following question:

So I have this rather large datafile. Unfortunately it somehow got corrupted. There are random newlines all over it. And what really should be the new line char is a +. What should be the record separator has turned into one of three different characters. Personally I don't believe the data is even correct, but the boss says to try and recover it anyway.

So I was thinking of doing something like open the file, loop through it and chomp out the newlines and stuff that all into a variable. Then do a regex (or probably more than one) on that variable to replace the chars. Then finally write that variable out to the output file.

The thing is we're looking at a pretty large file and stuffing that much data into a single variable seems like a pretty good way of crashing my box.

So are there any better ways of doing this?

Thanks in advance.