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

I am having problems i need to do a traceroute until my regex match is met i understand how qx works but my research indicates that there is a way i can use open maybe to accomplish what i need to accomplish.


#!perl use strict; use warnings; my $trace; my $ipaddy = "8.8.8.8"; #example do { $trace = qx{tracert $ipaddy}; until ($trace =~ /myhost/) }

Replies are listed 'Best First'.
Re: perl need to do until on qx{tracert $ip}
by NetWallah (Canon) on Sep 14, 2012 at 17:04 UTC
    Do you really want to run 'tracert' multiple (possibily infinite) times ?

    I'm guessing this is what you are want:

    my $found = 0; for (qx<tracert $ipaddy>){ next unless /myhost/; found = 1; last; }
    or, simpler,
    if (grep {/myhost/}, qx<tracert $ipaddy>){ #Do something }else{ #Addr was not found in trace }

                 I hope life isn't a big joke, because I don't get it.
                       -SNL