On Jun 5, Alan F. Larimer, Jr. said:
>> >>$old = $=;
>> >>$~ = "HEADER";
>> >>$= = 25; #cuz that's how many lines on the screen
>> >>(print some stuff with HEADER format)
>> >>$~ = "STDOUT";
>> >>$= = $old;
>> >>
>> >>I used a print statement to ensure that $= is being set properly,
>> and
>> >>it is. But when I print stuff with HEADER format, it seems to not
>> >>stick with that new $= = 25; Yes, the output is still going to
>> STDOUT
>> >>(screen), where I want it, but just not with the new
>> >>format_lines_per_page.
>> >
>> >How do you know this, Alan? Do you have a format_header set? If
>> not, I'm
>> >afraid you won't be able to tell where one "page" ends and the next
>> >begins.
>>
>> Rather, format_top_name, set via the $^ variables.
>
>Your first response did kinda confuse me, but now I see what you mean.
>Then my question becomes: Will the display wait for me to see the first
>screen before jumping to the next? Or do I need to implement that in
>some other way? (ie <STDIN>; # like getch() in C)
No. The FORMAT_LINES_PER_PAGE variable, $=, just holds how many lines get
printed per each header-content text. You'll need to make some sort of
pager for your program. In fact, $= isn't even needed, then.
#!/usr/bin/perl -w
use strict;
sub pager {
my ($fh, $func, $pause, $lines) = @_;
local (*READ, *WRITE, *FH, *SAVE);
pipe READ, WRITE;
*FH = $fh;
open SAVE, ">&FH";
open FH, ">&WRITE";
my $old = select FH;
$func->();
close FH;
close WRITE;
open FH, ">&SAVE";
close SAVE;
while (<READ>) {
print;
$pause->() if $. % $lines == 0;
}
close READ;
select $old;
}
pager(\*STDOUT, sub { print `ls -lag` }, sub { <STDIN> }, 20);
If you need an explanation of this code, I'll gladly give one in the
morning. Until then, I really need some sleep. ;)
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
Erus�ro Marillion -- wielder of Ringril, known as Hesinaur, the Winter-Sun
Are you a Monk? http://www.perlmonks.com/ http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter. Brother #734
** Manning Publications, Co, is publishing my Perl Regex book **