Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: Tie::File

by Revelation (Deacon)
on May 09, 2002 at 00:43 UTC ( [id://165222]=note: print w/replies, xml ) Need Help??


in reply to Performance Question

I would reccomend using Tie::File for this.
Frankly, rewriting the whole file to change just a few lines is a problematic situation with flat files. Although I would prefer some sort of database backend, Tie::File gives a database, without any necessary fields, etc.

You can read about Tie::File (Writen by Dominus) here, or go to cpan and download the module. Here's an example of how to edit a file from his article.
tie @lines, 'Tie::File', 'file' or die ...; for (@lines) { # Do your thing, only for lines that match this regex, or ar +e records that need to be changed. } untie @lines;
It should be quicker.
Gyan Kapur
gyan.kapur@rhhllp.com

Replies are listed 'Best First'.
Re: Re: Tie::File
by BUU (Prior) on May 09, 2002 at 03:10 UTC
    It might (dunno..) be quicker if your just changing a few dozen lines but if your trying to change *alot* of lines then its going tobe much, much slower.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2024-04-19 01:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found