in reply to Too much text
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 | |
by tye (Sage) on Aug 02, 2000 at 19:32 UTC |