Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: CountDownTimer for my program

by ww (Bishop)
on Feb 22, 2013 at 13:34 UTC ( #1020159=note: print w/ replies, xml ) Need Help??


in reply to CountDownTimer for my perl program,

Since you already have answers to your lazy (homework? job requirement?) question, TIMTOWTDI (but you'll need to adapt, almost trivially, to make this abort some other running program... by, for example, killing the other's PID or similar):

#! /usr/bin/perl use 5.016; # 1020073 # Timeout Timer w/o eval or SIG print "How many minutes? "; my $min = <>; chomp $min; my $time_remaining = ($min * 60); sub countdown { my $t_left = shift; while ($t_left > 0) { sleep 1; --$t_left; say "Seconds remaining: $t_left"; #elaborate this sub if you want + output in min:sec format } } say countdown($time_remaining); print "\a" x 5 . "\t\t $time_remaining countdown is finished\n";

But see also On asking for help & How do I post a question effectively? ... and start showing some effort!


If you didn't program your executable by toggling in binary, it wasn't really programming!


Comment on Re: CountDownTimer for my program
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1020159]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (11)
As of 2014-10-01 20:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (38 votes), past polls