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

Re: Speed differences in updating a data file

by CukiMnstr (Deacon)
on Apr 28, 2002 at 08:48 UTC ( #162638=note: print w/replies, xml ) Need Help??


in reply to Speed differences in updating a data file

This does not answer your question (the previous answers should give enough information anyway), but I thought you might find interesting a third method (it's always useful to have many tricks in the bag): try Tie::File, by Dominus. It lets you manipulate a file as a regular perl array (each file record -- one line is the default -- corresponding to an array element) without loading the whole file into memory, so it is particularly good when dealing with big files.

hope this helps,

  • Comment on Re: Speed differences in updating a data file

Replies are listed 'Best First'.
Re:x2 Speed differences in updating a data file
by grinder (Bishop) on Apr 28, 2002 at 17:10 UTC
    The other day in Performing a tail(1) in Perl (reading the last N lines of a file), Chmrr showed that Tie::File is much, much slower than simpler read-by-line methods for reading files. This was for getting the end of the file, so I suspect that while the file is not loaded into memory, it is still read sequentially from beginning to end. It would be wise to benchmark the different approaches before settling on the technique to use.


    print@_{sort keys %_},$/if%_=split//,'= & *a?b:e\f/h^h!j+n,o@o;r$s-t%t#u'

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2020-02-23 02:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What numbers are you going to focus on primarily in 2020?










    Results (102 votes). Check out past polls.

    Notices?