Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: multiple regexp matches in multi line string

by k_manimuthu (Monk)
on May 07, 2010 at 10:12 UTC ( #838904=note: print w/ replies, xml ) Need Help??


in reply to multiple regexp matches in multi line string

For your code, you used the greedy match (.*). You will use the non-greedy match (.*?) in your code, you will get all the addresses.

while($lines =~ m/traffic-gen.*?client address = 192\.0\.0\.(\d+).*?da +ta units received = (\d+).*?jitter/scgi) { print $1, "\tyes\t",$2,"\n"; push @ones, $1; push @twos, $2; }


Comment on Re: multiple regexp matches in multi line string
Download Code
Replies are listed 'Best First'.
Re^2: multiple regexp matches in multi line string
by wirelesscharlie (Initiate) on May 10, 2010 at 06:38 UTC
    Yes that worked!! Thanks :)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2015-07-28 04:23 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 (252 votes), past polls