-->
Term::ReadKey模块中的GetTerminalSizes可以判定屏幕大小
($cwidth,$cheight,$pwidth,$pheight)=GetTerminalSize STDOUT;
$cwidth,$cheigth为以字符为单位的屏幕的宽,高
$pwidth,$pheight为以像素为单位的屏幕的宽,高
[root@supersun tool2sort]# cat page.pl
#!/usr/bin/perl -w
use strict;
use Term::ReadKey;
my ($width,$height)=GetTerminalSize;
my $count=0;
ReadMode 'cbreak';
while(<>){
print "$.:$_";
if(++$count == $height-1){
last if lc(ReadKey 0) eq 'q';
$count=0;
}
}
ReadMode 'restore';

发表评论