Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Term::Twiddle on Win32 or how to use spinner

by icius (Sexton)
on Feb 14, 2003 at 21:35 UTC ( #235416=perlquestion: print w/replies, xml ) Need Help??

icius has asked for the wisdom of the Perl Monks concerning the following question:

Hello monks! I have been perusing the prolific "spinner" posts and there are a number of options out there. I am trying to get a spinner/status bar to work like the Term::Twiddle module, i.e.


do some other Perl stuff of my choosing


The spinners all look great but they are all infinite loops or counted loops. I need to be able to start and stop like above. The best solution would be if someone knows of a version of Term::Twiddle that works on Windows. The next best would be if someone knows how to use any of the spinners in the above fashion. Thanks!!
  • Comment on Term::Twiddle on Win32 or how to use spinner

Replies are listed 'Best First'.
Re: Term::Twiddle on Win32 or how to use spinner
by BrowserUk (Patriarch) on Feb 15, 2003 at 06:14 UTC

    Here's a roll-your-own asynchronous spinner using fork under Win32. It's pretty crude as-is, but could be fairly easily wrapped up in a nicer interface.

    Update: Added a 100ms sleep (select) to stop the spinner using half the CPU.

    #! perl -sw use strict; use Win32::Mutex; $|++; my $name = 'Spin_control'; if ( my $pid = fork() ) { my $n=0; my $mutex =Win32::Mutex->new(0,$name) or die $^E; while($mutex->wait() != -1) { $mutex->release(); print chr(13) . 'Busy'; print substr( '-\|/', $n++ % 4,1) . chr(8); select(undef,undef,undef,0.1); ## Added. } } elsif ( $pid == 0 ) { my $mutex = Win32::Mutex->open($name); $mutex->wait(); print 'Not busy' . chr(13) for 1..1000; print $/; $mutex->release(); my $count; $count++ for 1..1_000_000; $mutex->wait(); print 'Counted to ', $count; } else { warn 'fork() failed'; }

    Examine what is said, not who speaks.

    The 7th Rule of perl club is -- pearl clubs are easily damaged. Use a diamond club instead.

Re: Term::Twiddle on Win32 or how to use spinner
by tretin (Friar) on Feb 15, 2003 at 05:47 UTC
    I'd check this thread for your spinner needs. If anybody has term::twiddle on windows, CPAN could use it.

    sorry I can't be of more use, but hopefully you can find what you need there

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2022-05-24 21:38 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (84 votes). Check out past polls.