![]() |
|
Problems? Is your data what you think it is? | |
PerlMonks |
Re: Paging on input/fileby trantor (Chaplain) |
on Aug 04, 2004 at 08:20 UTC ( #379934=note: print w/replies, xml ) | Need Help?? |
If your program is not interactive, just follow the *NIX tradition, i.e. just print your output and let the user decide to page it if necessary, like: yourscript.pl | less If your program is interactive (i.e. it waits for input from the user) then this is not feasible. You can either write your own little pager using for example Curses, or you can yet again follow a well established *NIX convention and run the user's favourite pager, which is usually stored in $ENV{PAGER}. Using the user's pager has the definite advantages of not having to reinvent the wheel (think lazy (-;) and presenting the user with a well-known interface for viewing long files. If you use system, it is a good idea to pass a list and not a single scalar as an argument: the single scalar could be interpreted by the shell (for example if it has wildcards) with possibly nasty or anyway unwanted side effects.
In Section
Seekers of Perl Wisdom
|
|