P
Paul Branon
Hypothetically speaking: -
Say I have a file containing 100,000 numbers, and each number
corresponds to a database id
and I have another file which contains all of the database ids plus
the name of the file that corresponds to it.
(Why couldn't I do an sql query which puts all the info in one file?
Because I don't have access to the database!)
So, I have these two files! (The second file is much larger than the
first, say 300,000 records or more)
Now, the only way that I can match database ids to filenames is to
traverse list one and for each entry in list one then iteratively
traverse list two until a match is made
(In shell you would just use grep) what I'm doing is while <FILENAME>{
if ( $number =~ /\b$othernumber\b/){
carryoutmatch_behaviour;
}
}
It works. But it's relatively slow! (perhaps not surprisingly!)
Question) How would you solve the problem? (More quickly)
Say I have a file containing 100,000 numbers, and each number
corresponds to a database id
and I have another file which contains all of the database ids plus
the name of the file that corresponds to it.
(Why couldn't I do an sql query which puts all the info in one file?
Because I don't have access to the database!)
So, I have these two files! (The second file is much larger than the
first, say 300,000 records or more)
Now, the only way that I can match database ids to filenames is to
traverse list one and for each entry in list one then iteratively
traverse list two until a match is made
(In shell you would just use grep) what I'm doing is while <FILENAME>{
if ( $number =~ /\b$othernumber\b/){
carryoutmatch_behaviour;
}
}
It works. But it's relatively slow! (perhaps not surprisingly!)
Question) How would you solve the problem? (More quickly)