in reply to open and read file using cgi perl
An important question: how large are your files? Reading the complete second file for each line of input in the first file is most probably extremely inefficient. One of the most common way to do this type of thing is to store one of the files (often the smallest one, but not necessarily) in an appropriate data structure, often a hash or something similar, so that you can then read the other file line by line and access instantly to the data you need for the comparison. But this is not possible if your files are really huge and will exhaust memory.
If the files are really too large for that (i.e. the file won't fit into memory), there is still another possibility: sort both files according to the comparison key, and read them in parallel.
But don't read one file for each input line of the other. This is extremely inefficient.
|
|---|