Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Maximum End Time

by mantra2006 (Hermit)
on Sep 20, 2006 at 15:11 UTC ( [id://573906]=perlquestion: print w/replies, xml ) Need Help??

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

Hello Monks

In one script I am using the following statement to set the cutoff time.
I want to use the script in both ways like if the time is entered the script will
come out after that time is reached and if user
don't enter any time then it should not comeout
like forever loop
I used the following statement...basically 99:99 I just specified to
take maximum hours and mins...
local($ttim)=defined $ARGV[1] ? $ARGV[1] : "99:99";

Is there a good way to specify to get into infinite loop
Thanks & Regards
Sridhar

Replies are listed 'Best First'.
Re: Maximum End Time
by Limbic~Region (Chancellor) on Sep 20, 2006 at 17:14 UTC
    mantra2006,
    It sounds like what you want is alarm. The code would look something like:
    print $time_out_request_msg; my $time_out = <STDIN>; chomp $time_out; if (valid_timeout($time_out)) { $SIG{ALRM} = sub { # ... }; alarm $time_out; } while (1) { # ... }

    Update: The original node was modified by mantra2006 a couple of times after this reply so this reply may no longer be pertinent as a result.

    Cheers - L~R

Re: Maximum End Time
by Animator (Hermit) on Sep 20, 2006 at 20:48 UTC

    Please read Coping with Scoping. It is much cleaner to use my instead of local.

    Basically local is something you would use in Perl 4. In Perl 5 you almost always want my.

    You want to know how to use it and/or why you should use it? Read the page I mentioned earlier.

Re: Maximum End Time
by BigJoe (Curate) on Sep 20, 2006 at 17:08 UTC
    Can you add more code so we can see how you are looping? This will help us give you an answer to your question.


    --BigJoe

    Learn patience, you must.
    Young PerlMonk, craves Not these things.
    Use the source Luke.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (2)
As of 2024-04-26 03:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found