http://www.perlmonks.org?node_id=439218


in reply to Muy Large File

Update: As thor points out, my solution here is quite wrong. Sorry.

On unixy platforms, Perl has exactly what you need already built in. (Windows users may need a binmode somewhere.)

#!/usr/bin/perl -w -pi use strict; tr/A-Z/ /;

If your records do not have newlines at the end, then you will need to set the record length. Add the following line to the script, replacing 4096 with the record length:

BEGIN { $/ = \4096 }

The magic is in the -pi which turns on in-place editing in a loop (more at perlrun). Then the tr/// operator runs on every record, replacing the offending characters with spaces (more at perlop). Use tr/// instead of s///; it's probably faster and safer.

Note: Code is mostly untested. Use with caution.