Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: Muy Large File

by TilRMan (Friar)
on Mar 14, 2005 at 10:33 UTC ( #439218=note: print w/replies, xml ) Need Help??

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.

Replies are listed 'Best First'.
Re^2: Muy Large File
by thor (Priest) on Mar 14, 2005 at 13:28 UTC
    The problem is that while the -i switch is the "in place" switch, it isn't really in place. From perldoc perlrun
    It does this by renaming the input file, opening the output file by the original name, and selecting that output file as the default for print() statements.
    As per the OP, the file is too large to do this with.


    Feel the white light, the light within
    Be your own disciple, fan the sparks of will
    For all of us waiting, your kingdom will come

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://439218]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2016-10-22 19:13 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (297 votes). Check out past polls.