Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: how to update a field of a record in a large text file

by mickeyn (Priest)
on Mar 07, 2006 at 10:36 UTC ( #534876=note: print w/ replies, xml ) Need Help??


in reply to how to update a field of a record in a large text file

assuming you are familiar with the use of regular expressions (see 'perldoc perlre' if not), what you want is to perform a substitution using regular expression on this record.

to do it on a text file - I recommend tie'ing the file to an array and perform the substitution on the array. take a look at Tie::File.

example:

use Tie::File; tie @array, 'Tie::File', 'test'; foreach (@array){ s/RECORD/NEW RECORD/g; } untie @array;

Enjoy,
Mickey


Comment on Re: how to update a field of a record in a large text file
Download Code
Re^2: how to update a field of a record in a large text file
by CountZero (Bishop) on Mar 07, 2006 at 10:54 UTC
    That supposes of course that you know beforehand the content of the record to be searched (perhaps you only know its ID) and enough info on its fields to construct the regex to immediately replace the data of the field to be changed.

    CountZero

    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (13)
As of 2014-07-24 11:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (160 votes), past polls