Operating System - HP-UX
1838263 Members
3619 Online
110125 Solutions
New Discussion

Re: print multiple lines that act as more in Perl

 
SOLVED
Go to solution
Ratzie
Super Advisor

print multiple lines that act as more in Perl

I have created a multi variable, that displays alot of information, when I print, the top part scrolls off the screen as if you do a cat on a long file.
How can I make a this print $multi, "/n"; Act like the more command in unix. Even display "hit enter to continue" then carry on with the rest for the info and the script.

my $multi =" lots of info...";
print $multi, "/n";
3 REPLIES 3
Rodney Hills
Honored Contributor
Solution

Re: print multiple lines that act as more in Perl

You can call the "more" command from perl-

Here is an example-

perl -e 'open(OUT,"|more"); print OUT "hello\nthere\nyou\nuser\nyou.\n";close(OUT)'

HTH

-- Rod Hills
There be dragons...
H.Merijn Brand (procura
Honored Contributor

Re: print multiple lines that act as more in Perl

of course that "/n" should be "\n"

For more/less functionality, you could also use modules

Simple:
http://search.cpan.org/~jaw/Term-Pager-1.00/

use Term::Pager;

my $t = Term::Pager->new (rows => 25, cols => 80);
$t->add_text ($text);
$t->more ();

or

http://search.cpan.org/author/JPIERCE/IO-Pager-0.05/lib/IO/

use IO::Pager;

{ local $STDOUT = new IO::Pager *STDOUT;
print $multi;
}

Graphical in Tk:
http://search.cpan.org/author/SREZIC/Tk-Pod-0.9927/

Enjoy, Have FUN! H.Merijn
Ratzie
Super Advisor

Re: print multiple lines that act as more in Perl

Thanks