
PerlyDan
New User
Nov 3, 2003, 7:00 AM
Post #1 of 3
(318 views)
|
|
(In)efficient way of counting linesin a file?
|
Can't Post
|
|
Hi, This code seems to be taking a long time to execute. I want to count the number of lines in a set of files. Each file is about 3 million lines each. Is the code VERY inefficient? Would there be a better way of doing this? (Running on Win 2000). Thanks, Dan open(LIST, "intfileList.txt")||die "$!: "."intfileList.txt\n"; open OUT, ">RowCounts.txt"; foreach(<LIST>){ chomp $_; open(FILE,"$_") or print OUT "$!: "."$_\n"; if (-e $_){ @arr=<FILE>; $count=@arr; print OUT "$_ = $count\n"; } }
|