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

perl need to do until on qx{tracert $ip}

by diamondsandperls (Beadle)
on Sep 14, 2012 at 16:23 UTC ( #993753=perlquestion: print w/ replies, xml ) Need Help??
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/) }

Comment on perl need to do until on qx{tracert $ip}
Download Code
Replies are listed 'Best First'.
Re: perl need to do until on qx{tracert $ip}
by NetWallah (Abbot) 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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (11)
As of 2015-07-28 08:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (254 votes), past polls