Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Recommended data file size..? 2

Status
Not open for further replies.

blitzer

Programmer
Jun 18, 2001
34
CA
How long (# of lines) do you think data files should get to be before you tell the script to start a new file? I'm worried about load time when a new line is added. I figure that telling a script:

print file "blah\n";
foreach (@file) { print file "@file\n"; }

.. takes a long time to load if the file has 10,000+ lines.. but I could be wrong because I don't know how Perl works.

thanks.
 
As far as i can tell, it doesn't read the file when appending or writing, just checks where the end is (when appending) and writes to there.
i've writtern a perl message board, and iuse append to add replies to posts, sometimes, on hot topics, these data files ceanget ot be 1000+ lines.. and it doesn't appear any slower than when it originlly writes the file
Siberdude
siberdude@settlers.co.uk
 
Code:
print file "blah\n";
foreach (@file) { print file "@file\n"; }
If @file is an array of 10,000 elements, your code will write out the entire array 10,000 times.

I think your second line should be either
Code:
foreach (@file) {print file "$_\n"; }
or
Code:
print file @file, "\n";
With the second option you can add a "\n" between each array element by setting the list separator ($") to "\n"
before executing the print statement.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top