Created
April 19, 2009 21:24
-
-
Save beppu/98237 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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