一个简单的分页脚本

| 暂无评论 | 暂无引用通告

-->

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';

暂无引用通告

发送引用通告网址: http://supersun.info/mt/mt-tb.cgi/699
如果您想引用这篇日记到您的Blog,请复制上面的链接,放置到您发表文章时的相应界面中。

发表评论

最新资源

  • IMG_1437.JPG
  • line.png
  • bar.png
  • perl_calander.jpg

关于此日记

此日记由 supersun 发表于 2007年8月13日 18:10

此Blog上的上一篇日记计算网络掩码的脚本

此Blog上的下一篇日记perl中屏蔽多行代码

首页归档页可以看到最新的日记和所有日记。