Gossamer Forum
Home : General : Perl Programming :

Clearing STDOUT

Quote Reply
Clearing STDOUT
I'm looking for a way to clear STDOUT. I don't want to use 'flush' as I believe that goes ahead and sends what was already written to the filehandle. I need to clear it out completely, to prepare for new output (used for an error handling routine).

Any suggestions would be appreciated.
Quote Reply
Re: [redbopete] Clearing STDOUT In reply to
Use:

`clear`;

or

qx/clear/;

....this isn't available on all systems.

Last edited by:

Paul: Jun 6, 2002, 3:46 AM
Quote Reply
Re: [redbopete] Clearing STDOUT In reply to
  1. Try making a system call, e.g.,

    Code:
    use system();
    system ('cls'); # or equivalent on your system.


  2. Or look into the Term::Cap module available on CPAN.

    Code:
    use Term::Cap;

    $t = Tgetent Term::Cap {TERM=>undef, OSPEED=>9600};

    print $t->Tputs("cl");


  3. Or you could look at an even simpler module found again on CPAN, called Term::Screen, which allows you to do something like:

    Code:
    use Term::Screen;

    my $terminal = new Term::Screen;

    $terminal->clrscr();

Hope this helps.

- wil
Quote Reply
Re: [Wil] Clearing STDOUT In reply to
You don't need to load system to do a system call.

If you are going to do it that way you may want some error checking.

system('cls') == 0 or die "system('cls') failed: $?";

$exit_value = $? >> 8;
$signal_num = $? & 127;
$dumped_core = $? & 128;
Quote Reply
Re: [redbopete] Clearing STDOUT In reply to
And just out of curiosity...Why would you want to clear STDOUT, what is the significance of this?



Crapshoot70 (this isn't my real name)
--
I don't like anyone...but everyone LOVES me Unsure
--
AKA...The Post Pirate Pirate