Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

while loop

by azaria (Beadle)
on Apr 25, 2006 at 13:20 UTC ( [id://545557]=perlquestion: print w/replies, xml ) Need Help??

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

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: while loop
by Zaxo (Archbishop) on Apr 25, 2006 at 13:43 UTC

    The logic for that could look something like this:

    sub notfree { # returns true if license not free # whatever you do with parsing lmstat } LOOP: { if (notfree @args) { sleep $sane_interval; redo LOOP; } else { system( @other_args); } }
    I'm not entirely clear on what you want, but that should be close. I didn't include the logout part because that doesn't sound right to me. Most unix commands don't do that to the user. Could you describe what you're doing in more detail, so we can understand your requirements better?

    After Compline,
    Zaxo

      By "logout", I think he means "free the license handle".
Re: while loop
by mantadin (Beadle) on Apr 25, 2006 at 13:34 UTC
    I'm not sure what exactly your question is. Do you want to do something like
    while (not &license_free) { sleep $a_few_seconds; } &execute_command_and_logout;

      Well, quite about the only answer that such a question deserves. But while you're there, and the op is clearly a newbie, please do not use the &-form of sub call, since we take care all the time of deprecating it to avoid this cargo-culted remnant from Perl 4 to spread further. If you want to underline that you're doing a sub call, then you may use empty parens...

        Thanks for the info; I did not know that the &-form is considered a cargo-culted remnant.

        OTOH, I am not aware of the &-form having any useful advantage. AFAIK, &f, if called from within another sub, is equivalent to f(@_) "but faster", as the camel books states (3rd edition, Chapter 6, scoping issues).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2024-04-24 19:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found