Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

How to make a timer with breaks

by xdfreaknikdx (Initiate)
on Sep 28, 2014 at 23:06 UTC ( [id://1102298]=perlquestion: print w/replies, xml ) Need Help??

xdfreaknikdx has asked for the wisdom of the Perl Monks concerning the following question:

(Hi I need to add countdown timer to my perl program which starts from 00:01:00(1 minute)when I start running the script and in every 00:00:10 (10 seconds) the timer stops and the program will asks if you want to continue or stop the countdown. Thanks in advance.)

Replies are listed 'Best First'.
Re: How to make a timer with breaks
by Anonymous Monk on Sep 29, 2014 at 02:21 UTC
Re: How to make a timer with breaks
by MidLifeXis (Monsignor) on Sep 29, 2014 at 13:00 UTC

    This sounds like a homework question (a question requiring a couple of concepts without an obvious real-world application). Don't be afraid to state that it is.

    That being said, if I were to implement this, I would want a few items:

    • A counter to store the remaining time (perhaps a global variable or a lexical variable or a Time::DurationTime::Interval or some other Interval object or some such; perlsyn for some background reading)
    • A method to decrease the counter (see perlop and search for decrement)
    • A method to display the counter in the correct format. (see printf as one option)
    • A method to determine if I am at a 10 second mark (see perlop and search for modulo)
    • A method to prompt a user for input (printf or Prompt might be useful)
    • A method to compare strings (see perlop for the difference between eq/ne and ==/!= or perlretut for regular expression help)
    • A method to break out of a loop (see perlsyn for last and next)

    Show your work, be honest about the homework status, ask questions. Just like coursework, you tend to get more out of PerlMonks if you put more of yourself into it.

    --MidLifeXis

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1102298]
Approved by Corion
Front-paged by toolic
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2024-04-23 12:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found