On Wed, Aug 19, 2009 at 11:03, Tony Esposito<tony1234567...@yahoo.co.uk> wrote:
> Anyone have the code that make the 'clock' show when a Perl program is 
> running?
> What I mean by the 'clock' is the command-line movement that sequentially 
> does the following (in place):
>
> - \ | / - \ | /
snip

#!/usr/bin/perl

use strict;
use warnings;

my @spinner  = qw{ - \ | / - \ | / };
my @throbber = qw{ . o O o };

$| = 1;

print "waiting: ";
while (1) {
        my $spinner_frame  = shift @spinner;
        my $throbber_frame = shift @throbber;

        print "$throbber_frame $spinner_frame";

        push @spinner, $spinner_frame;
        push @throbber, $throbber_frame;

        #wait a tenth of a second
        select undef, undef, undef, .1;

        print "\b\b\b";
}



-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to