Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

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 = ""; #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 (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.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (8)
As of 2016-10-22 09:16 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (294 votes). Check out past polls.