Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

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.


Comment on Re: Muy Large File
Select or Download Code
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.

    thor

    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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2014-11-01 02:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (227 votes), past polls