Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

A stupid sdtio problem

by E-Bitch (Pilgrim)
on Jun 13, 2001 at 03:42 UTC ( #87964=perlquestion: print w/replies, xml ) Need Help??

E-Bitch has asked for the wisdom of the Perl Monks concerning the following question:

Okay, now I know this seems pointless, but humor me. I have seen several command line utilities do this, and I know it can be done. That being said, what I want to accomplish is during the execution of a program ( a file processing program meant to parse through about 28000 files (about 300,000 lines), to be more specific), I would like to show the user that the program is doing something. I have tried printing and endless stream of '.'s out about every 1000 lines or so, but that fills up the damned terminal window... so what I want to do is display the following characters, so they overlap eachother (giving the optical illusion of rotation): | \ - / If this is done correctly, the pipe will be displayed, followed by the backslash overtop of it, then the dash, then the forward slash, and all of this without disturbing what is already on the screen... so any takers out there?
Thanks!
E-Bitch

Replies are listed 'Best First'.
Re: A stupid sdtio problem
by bikeNomad (Priest) on Jun 13, 2001 at 04:06 UTC
    You can use the "\r" character to return to the first column. Or the "\b" character to backspace:
    $|++; # unbuffer STDOUT my @chars = qw(| \ - /); my $lastChar = 0; sub stick { my $msg = shift; $lastChar = ++$lastChar % 4; print "\r$msg", $chars[ $lastChar ]; } for (1..10000) { stick("Testing: "); select(undef, undef, undef, 0.1); }
Re: A stupid sdtio problem
by ZZamboni (Curate) on Jun 13, 2001 at 05:59 UTC
    See this thread for several good ideas on how to do this.

    Also, it might help in the future to use a more descriptive title for your nodes.

    --ZZamboni

Re: A stupid sdtio problem
by AgentM (Curate) on Jun 14, 2001 at 03:10 UTC
    Well, you certainly have come across the limits of stdio.h. I heartily recommend the use of Curses which will give you nice colors and even a chance to build a "window" with a progress indicator bar and perhaps even a cancel "button". What's even better is that it is cross-platform and the API is simple.
    AgentM Systems nor Nasca Enterprises nor Bone::Easy nor Macperl is responsible for the comments made by AgentM. Remember, you can build any logical system with NOR.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2019-06-27 08:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Is there a future for codeless software?



    Results (111 votes). Check out past polls.

    Notices?