Skip to content

Instantly share code, notes, and snippets.

@beppu
Created April 19, 2009 21:24
Show Gist options
  • Select an option

  • Save beppu/98237 to your computer and use it in GitHub Desktop.

Select an option

Save beppu/98237 to your computer and use it in GitHub Desktop.
#!/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