Originally Posted by zerobane
seems difficult for such a simple thing... Maybe im going about this wrong...
What i'm trying to do is print a array that is greater then 1 screen big...
What would be the best way to parse the output?
original plan was to if linecount == count then pause...
This would also work nicely when you are putty'd as the LINES var changes with screen size...
any better ways (couple of scripts i looked at are using | more, which seems kind of "hacky")
This is either more or less complicated than it seems. It's less complicated if the script is just for you, not especially important and you want something simple to print out a static list. In that case, run your Perl script and pipe its output to the pager of your choice:
perl my_script | less
As a general rule, I prefer to do it this way - call the pager in the shell - rather than explicitly send output to the pager inside my Perl script, for a couple of reasons. One, not every computer has the same pagers available, and so then I have to allow for fallbacks. Two, I know that I won't always
want paged output. Sometimes I will want to redirect the output to a file. If I hardcode that the output goes to a pager, then I'm handcuffed.
However, if this is for production code for a client or many users, then I wouldn't mess around. Look on CPAN
. There are many solid modules available that will (1) gather information about the terminal that is running and (2) page through output. This is a more reliable solution for a bigger or more significant piece of code since it's more portable (the paging is done via Perl; you don't rely on what pagers are available) and it can allow for different users who have different sized screens. The first-thought idea of 'line_count == count, then pause' doesn't really work since my terminal may has 24 lines, but Sergei's has 70. If you page every 65 lines, you overrun my terminal by quite a lot. If you page by 20, you annoy the hell out of him. You need your solution - if it's a real application - to allow different users to differ.