Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^3: File search using Grep

by Anonymous Monk
on Jun 26, 2009 at 14:35 UTC ( [id://775063]=note: print w/replies, xml ) Need Help??


in reply to Re^2: File search using Grep
in thread File search using Grep

Hi, Thanks to all your suggestions; My problem is just to get the information particular to an account using his unique id; some of them will not be in the list also. We are expecting that this file will have millions of records as the accounts grow. So thinking of whether to store these records in hash each time the script is called or to just grep it? Thanks Priya

Replies are listed 'Best First'.
Re^4: File search using Grep
by zwon (Abbot) on Jun 26, 2009 at 19:20 UTC

    Is there any reason not to use database?

Re^4: File search using Grep
by mzedeler (Pilgrim) on Jun 27, 2009 at 19:28 UTC

    Using grep or perl -ne 'print if /<expr>/' is linear search, which is an operation that will scale with the size of the file. If the file is double the size, you can expect it to take twice as long time.

    If you use a different storage format, such as dbm or the like, you can improve this performance significantly, but it has nothing with the way the file is being read - its all about the format of the file.

    If you still want to keep the flat file you have described, you can build an index in a separate and use that for look up. One tool that will allow you to index the data is Berkeley DB for which there is the DB_File module.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-04-19 02:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found