http://qs321.pair.com?node_id=379934


in reply to Paging on input/file

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.