如何在 Perl 中一次输出一屏
When executing a Perl script from the command line, how can I ensure that my output doesn't scroll off the screen?
In other words, how do I mimic the functionality of the Unix more or less commands?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Term::Pager 模块似乎就是您正在寻找的模块。
The Term::Pager module would seem to be what you're looking for.
用户只需将输出传送到
less
即可。这使他们可以选择使用自己喜欢的寻呼机,或者甚至根本不使用任何寻呼机(如果他们愿意)。The user can just pipe the output to
less
. That gives them the option of using their favourite pager, or even not using any pager at all, if they prefer that.正如 Matti Virkkunen 所说 ,用户最好将您的脚本传送到
less
。类 Unix 系统的用户希望以纯文本形式输出,因此如果需要,他可以将其传递给其他命令。如果您的脚本不将输出显示为纯文本,您的用户可能会发现您的脚本不太可用。
As Matti Virkkunen says, it's better that the user pipes your script to
less
.A user of a Unix-like system would expect output in plain text, so (s)he can pipe it to other commands if they need to. Making your script not displaying output as plain text, your user may find your script less usable.
对于一种快速而肮脏的方式,您可以将文本通过管道传输到less或more:
有各种less和more< /em> 标志允许脚本在到达文本底部时继续。
For a quick-and-dirty way, you can pipe the text to less or more:
There are various less and more flags to allow the script to continue when it reaches the bottom of the text.