Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
#!/usr/bin/perl
# countdown = sleep + verbosity
# countdown 300 && wget http://wu.sauceruney.com/digitrash/freemanradio/RadioFreeman01.mp3
use strict;
use warnings;
use AnyEvent;
$| = 1;
my $duration = shift;
my $count = $duration;
my $len = length($count);
my $done = AnyEvent->condvar;
my $w = AnyEvent->timer(
after => 0,
interval => 1,
cb => sub {
printf "[%${len}d/%${len}d]\r", $count--, $duration;
$done->send if ($count < 0);
}
);
$done->recv;
print "\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment