I am trying to display a 1000 lines or so at a time in a Tk ROText widget and I thought this tie could work. I'll go back to while ( <FH> ) and tells and seeks and see if that gives me better performance.

You might find some relevant ideas in this older thread: Displaying/buffering huge text files.

If you decide to take the time to index the byte offsets to all the line-endings in your log file, that will surely end up providing much better performance, but if the log file changes over time, you'll be updating the index constantly. Of course, that'll be a simple process of appending more byte offsets as more lines are added, but it's likely that the index will become unwieldy (maybe the line count is such that indexing all the lines is already unwieldy).

If the goal is simply to be able to show a good-sized chunk of lines in a Tk ROText window, maybe you don't really need accurate info about where the line endings are. Just use reasonable estimates where necessary, along the following lines:

$requested_start = ...; # a value between 0 and 1 $avg_line_len = ...; # make a guess or read a small sample to est +imate this $file_size = -s $filename; $read_length = $avg_line_len * 1000; seek( FH, $file_size * $requested_start, 0 ); read( FH, $text, $read_length ); $text =~ s/^.*\n//; # trim initial and final $text =~ s/.*$//; # line fragments from $text

In reply to Re^3: file size limit with Tie::File by graff
in thread file size limit with Tie::File by alw

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.