LMPX.COM |
Home | Linux | Mysql | PHP | XML | ||
|
|
|||
From: comdog@cvs.perl.org Date: Mon Jun 23 00:50:15 2008 Subject: [svn:perlfaq] r11440 - perlfaq/trunk
Author: comdog
Date: Sun Jun 22 23:50:14 2008
New Revision: 11440
Modified:
perlfaq/trunk/perlfaq7.pod
perlfaq/trunk/perlfaq8.pod
Log:
* perlfaq8: How do I clear the screen?
+ Expanded answer to cover Term::ANSIScreen and Win32::Console
Modified: perlfaq/trunk/perlfaq7.pod
==============================================================================
--- perlfaq/trunk/perlfaq7.pod (original)
+++ perlfaq/trunk/perlfaq7.pod Sun Jun 22 23:50:14 2008
@@ -238,6 +238,7 @@
=back
=head2 How do I create a class?
+X<class, creation> X<package>
(contributed by brian d foy)
Modified: perlfaq/trunk/perlfaq8.pod
==============================================================================
--- perlfaq/trunk/perlfaq8.pod (original)
+++ perlfaq/trunk/perlfaq8.pod Sun Jun 22 23:50:14 2008
@@ -169,23 +169,49 @@
=head2 How do I clear the screen?
-If you only have do so infrequently, use C<system>:
+(contributed by brian d foy)
- system("clear");
+To clear the screen, you just have to print the special sequence
+that tells the terminal to clear the screen. Once you have that
+sequence, output it when you want to clear the screen.
-If you have to do this a lot, save the clear string
-so you can print it 100 times without calling a program
-100 times:
+You can use the C<Term::ANSIScreen> module to get the special
+sequence. Import the C<cls> function (or the C<:screen> tag):
- $clear_string = `clear`;
- print $clear_string;
+ use Term::ANSIScreen qw(cls);
+ my $clear_screen = cls();
+
+ print $clear_screen;
-If you're planning on doing other screen manipulations, like cursor
-positions, etc, you might wish to use Term::Cap module:
+The C<Term::Cap> module can also get the special sequence if you want
+to deal with the low-level details of terminal control. The C<Tputs>
+method returns the string for the given capability:
use Term::Cap;
- $terminal = Term::Cap->Tgetent( {OSPEED => 9600} );
+
+ $terminal = Term::Cap->Tgetent( { OSPEED => 9600 } );
$clear_string = $terminal->Tputs('cl');
+
+ print $clear_screen;
+
+On Windows, you can use the C<Win32::Console> module. After creating
+an object for the output filehandle you want to affect, call the
+C<Cls> method:
+
+ Win32::Console;
+
+ $OUT = Win32::Console->new(STD_OUTPUT_HANDLE);
+ my $clear_string = $OUT->Cls;
+
+ print $clear_screen;
+
+If you have a command-line program that does the job, you can call
+it in backticks to capture whatever it outputs so you can use it
+later:
+
+ $clear_string = `clear`;
+
+ print $clear_string;
=head2 How do I get the screen size?
| Navigate in group perl.cvs.perlfaq at sever nntp.perl.org | |
| Previous | Next |
| © No Copyright You are free to use Anything |
Site Maintained by PHP Developer
Powered By PHP Consultants |