in reply to Re^6: search a large text file
in thread search a large text file
Do you mean "many times instead of one or two times" ? (one or two) == (few) in the english language? I don't see the rest of your script, so I can only guess:
1) Did you call the sub "to_hash" more than once ? "to_hash" should be executed once and then never again. And with "once" I mean once in your lifetime and not once per execution of the script. Whenever you want to search, just use "my $db = DBM::Deep->new( "$file.db" );" and start to search. Remember that the file $file.db is permanent on your disk and keeps the info between invocations of your script. Call "to_hash" twice and you also get twice the values.
Additionally you might want to add "$db->clear()" to your "to_hash" subroutine so that even if you have to call it twice (because the source file changed), you get an empty hash before filling it.
2) Maybe your search routine prints out more than you want
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: search a large text file
by perl_lover_always (Acolyte) on Feb 10, 2011 at 10:25 UTC | |
by jethro (Monsignor) on Feb 10, 2011 at 10:45 UTC | |
by perl_lover_always (Acolyte) on Feb 10, 2011 at 13:47 UTC | |
by jethro (Monsignor) on Feb 10, 2011 at 15:37 UTC |