Something like:
should work even under Windows. I think it'd work under even more OSes so long as you set PAGER or have a version of "more" installed.my $pager= $ENV{PAGER} || "more"; open STDOUT, "| $pager" or warn "Not paging STDOUT: $!\n";
But, in testing this, I did find one wrinkle. Under Win32, the process model is rather basic and I couldn't find a way to get the shell to wait for "more" to finish. Here is the closest I came which seems to demonstrate a bug:
so the close fails which means that "more" never gets EOF and never exits. Note that the wait really shouldn't be there as an explicit close on a piped command does a wait. I just added that when Perl wasn't waiting for "more" to exit [ which made Perl wait forever which made me wonder why close wasn't sending an EOF which made me add the warn which showed me a bug in Perl -- now where is my prize? ;-) ].perl -le "open STDOUT, '| more'; $|=1; print for 0..50; close(STDOUT) +or warn $!; wait" ... Bad file descriptor at -e line 1. ...
So on OSes where Perl isn't broken (: you'd probably want to add:
so that Perl sends "more" an EOF and then waits for "more" to exit. - tye (but my friends call me "Tye")END { close(STDOUT) }
In reply to (tye)Re: Paging STDOUT?
by tye
in thread Paging STDOUT?
by ziva
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |