in reply to until Loop Question

You need something in the until block that will change the state of the condition variable. They also don't usually take else blocks. Besides that, all your block is doing is returning whatever was captured from the external ping command. Worse yet, since the assignment to $ping is waiting on an external command, it'll wait until the ping stops.

Net::Ping is the way to go.

Replies are listed 'Best First'.
Re: Re: until Loop Question
by ellem (Hermit) on Dec 14, 2001 at 05:51 UTC
    Clearly I am confused on the usage of the until loop. And while I have reworked the code to avoid the until loop entirely I would be interested to see how someone would correctly write:

    until something changes do this else do that

    or am I now hoplessly confused?
    --
    lmoran@wtsg.com
    There's more than one way to do it, just don't use my way.
      do{ ## do something that may or may not change $condition } until( $condition )

      ... this will execute the block after "do" until the expression after "until" evaluates to true. more examples....

      ## print "foo" until $count becomes 5 my $count = 0; do{ print "foo\n"; $count++; } until ( $count == 5 ); ## call some command until its exit status ## is 0 ( success ) do { system( "cmd" ); } until( $? == 0 );