The Tie::File object keeps track of where every line starts as it reads the file (in an array reference), so as you 'push' new lines on the end of the file, that array will grow bigger. It has to read every line to get to the end of the file so that it knows at what 'index' the current last line is, so there is an entry in that array for every line in your file. Then this array is a direct index into the lines of your file via
seek.
I don't know how easy it would be to add an option to make Tie::File 'forget' where some of the lines start, but that is what it would take. Maybe there could be an option to 'forget' where the first N lines started, or just keep track of every Nth line, either way, it would take some programming. (Update: Or better yet, an option to not even remember where any line starts until it "needs to know", so you could push to your heart's content and not eat up memory).
Maybe Tie::File is not the answer for you at this point if all you want to do is add a few lines to the end of a large file.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.