[Israel.pm] Slow file reading

Shmuel Fomberg semuelf at 012.net.il
Thu Oct 26 13:30:34 PDT 2006

Hello There.

I had a need to compare the content of two files.
Each of the files was 320kb, containing 65K lines, 5 characters per line
representing a 4-digit hexadecimal number and a \n. 
The trivial answer was:
@list1 = <FILE1>;
@list2 = <FILE2>;
And then I had an interesting phenomenon. The reading of the first file
always ended almost instantly, but the reading of the second file took
about 30 seconds. And it was always the second reading, even if I
slurped the files in reversed order.
I work on Win32, ActiveState Perl 5.6. It happened on various computers.
Anyone heard something about this?

What I did to bypass the problem was to read them as binaries, and split
the results. That worked fast.


More information about the Perl mailing list