Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

How do you clear the screen?

by Anonymous Monk
on Jun 19, 2000 at 11:27 UTC ( [id://18774]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question: (input and output)

How do you clear the screen?

Originally posted as a Categorized Question.

Replies are listed 'Best First'.
Re: How do you clear the screen?
by cleen (Pilgrim) on Jun 19, 2000 at 17:20 UTC
    use Term::Cap. use the POSIX module to probe certain features of the terminal.
    #!/usr/local/bin/perl use POSIX; use Term::Cap; # General terminal line I/O my $termios = new POSIX::Termios; $termios->getattr; # Extract the entry of the terminal type my $term = Term::Cap->Tgetent( { OSPEED => $termios->getospeed } ); # clear $term->Tputs('cl', 1, STDOUT);
Re: How do you clear the screen?
by AgentM (Curate) on Mar 22, 2001 at 23:13 UTC
    use Curses:
    use Curses; initscr(); refresh(); #use Curses calls for the rest of your program
Re: How do you clear the screen?
by MrNobo1024 (Hermit) on Mar 23, 2001 at 04:45 UTC
    Shell out and ask the OS to do it:
    system $^O eq 'MSWin32' ? 'cls' : 'clear';
Re: How do you clear the screen?
by osfameron (Hermit) on Mar 23, 2001 at 15:50 UTC
    use Win32::Console:
    $CONSOLE->Cls(); $CONSOLE->Cls( $FG_WHITE | $BG_GREEN );
    Where $CONSOLE is your blessed Console object.
Re: How do you clear the screen?
by wil (Priest) on May 27, 2002 at 10:07 UTC
Re: How do you clear the screen?
by arhuman (Vicar) on Mar 22, 2001 at 12:51 UTC
    # vt100 compliant terminal needed print "\033[2J";
Re: How do you clear the screen?
by OeufMayo (Curate) on Mar 22, 2001 at 23:27 UTC

    Come on! I'm surprised no one proposed this classic one:

    print " " x 80*25;

    You might want to modify the values to fit your screen

Re: How do you clear the screen?
by Anonymous Monk on Mar 22, 2001 at 08:08 UTC
    Another, less complex method would entail:

    print `clear` , "\n";
    
      Why the print stuff?

      This is enough:

      system('clear');
      But it only works on *nix systems, it fails on win32.
Re: How do you clear the screen?
by softworkz (Monk) on Jul 10, 2001 at 17:08 UTC
    I'm running activestate perl 5.6.1 for mswin32 and I have found that system ("clear"); doesn't work but the following code works fine.
    #!/usr/bin/perl-w use strict; use Win32; system ("cls");
      i'm running Win2000~
      I:\tmp>clear 'clear' is not recognized as an internal or external command, operable program or batch file.
      so system("clear") won't work because it's not a windows command. "cls" is.

      ~Particle

Re: How do you clear the screen?
by iFly (Initiate) on Feb 17, 2009 at 08:03 UTC
    You could invoke the (system-specific) external command:
    system "cls"; # dos system "clear"; # unix

    Originally posted as a Categorized Answer.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://18774]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2024-04-24 18:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found