Writing a pager isn't that hard.

You might want to use sys* commands to avoid Perl buffering:

  • sysopen your file
  • sysseek to the position
  • Read a fixed length block and look for a line ending
  • Show a line if you find a break, read another block if there is no line ending left
  • Repeat the last two steps until as much lines are shown as you like
  • You may want to save the positions of the last line beginnings using systell to directly sysseek to lines above and below the current screen.

    Writing a complete less-like pager may be require more features, but a basic one may also do the job if you're only viewing logfiles.

    I try to use the head and tail Linux commands to limit the number of lines when working with huge logfiles, for example "tail -n 25000 httpd/access.log" to get a day on a medium busy webserver. grep is also good if you're searching for specific information, less and it's coloring will do a good job when viewing the results.


    In reply to Re: pager written in perl? by Sewi
    in thread pager written in perl? by perl5ever

    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.