in reply to Using a thread to provide visual feedback.

Try something like this:

#! perl -slw use strict; use threads; use threads::shared; sub nap { select '','','', $_[0] } my $done:shared = 0; my $thread = async( sub { $|++; until( $done ) { nap( 0.1 ), printf "\r%s\t\t", '.' x $_ for 1 .. 10, reverse +1 .. 10; nap( 0.01 ), printf "\r%s\t\t", '.' x $_ for 1 .. 10, reverse +1 .. 10; nap( 0.8 ); } }, $done ); sleep 60; $done = 1; $thread->join;

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". The enemy of (IT) success is complexity.
In the absence of evidence, opinion is indistinguishable from prejudice. Suck that fhit

Replies are listed 'Best First'.
Re^2: Using a thread to provide visual feedback.
by marioroy (Prior) on Jun 22, 2018 at 15:10 UTC

    For folks using Perl not built to support threads and wanting to try BrowserUk's example, here is the same thing using MCE::Hobo and MCE::Shared.

    #! perl -slw use strict; use MCE::Hobo; use MCE::Shared; sub nap { select '','','', $_[0] } tie my $done, 'MCE::Shared', 0; my $hobo = mce_async( sub { $|++; until( $done ) { nap( 0.1 ), printf "\r%s\t\t", '.' x $_ for 1 .. 10, reverse +1 .. 10; nap( 0.01 ), printf "\r%s\t\t", '.' x $_ for 1 .. 10, reverse +1 .. 10; nap( 0.8 ); } }, $done ); sleep 10; $done = 1; $hobo->join;
Re^2: Using a thread to provide visual feedback.
by stevieb (Canon) on Jun 22, 2018 at 02:45 UTC

    This, right here, is why I think BrowserUk magically finds threads like this.