in reply to Too much text

Unless you've landed in a very inhospitable environment--like, say, Windows--you should be able to take advantage of the native tools. For example:
local $SIG{PIPE} = 'IGNORE'; open PAGER, '|'.($ENV{PAGER} || 'less') or die "Can't spawn pager: $!\n"; while (something) { print PAGER something_else; } close PAGER;

The (temporary) assignment to $SIG{PIPE} keeps your program from dying if the pager quits early. If you're concerned about wasting time generating useless data, you may want to add this refinement:

select PAGER; $| = 1; while (something) { print something_else or last; }

Remember, tool use is one of the things that make us human. :-)

UPDATE:Thanks to agoth for the bug fix. And yes, tye, I know that Windows has a "more" command. But it's so hostile that I never use it. There is a Windows port of "less", anyway.

    -- Chip Salzenberg, Free-Floating Agent of Chaos

Replies are listed 'Best First'.
query: Too much text
by agoth (Chaplain) on Aug 02, 2000 at 16:36 UTC
    But

    open PAGER, ($ENV{PAGER} || 'less') . '|' or die "blah $!";

    Doesn't open a pipe to the pager, least not on my system? (main::PAGER only opened for input), Am I missing something? But thanks for leading me to:

    open PAGER, ('|' . $ENV{PAGER}) or die "blah $!";

      Correct. And that should be

      $ENV{PAGER} || 'more'

      so that it works on Windows (contrary to the original proposers claim) and on many other systems that may not have 'less' installed.