From this data file i need to extract the client address 192.168.0.(\d+) and the corresponding data units received. I tried the follwing:1, , , Transport, TCP,Total Packets with Er +rors = 0 1, , , Transport, TCP,Packets Received w +ith Checksum Errors = 0 1, , , Transport, TCP,Packets Received w +ith Bad Offset = 0 1, , , Transport, TCP,Packets Received t +hat are Too Short = 0 1, ,[1024], Application,TRAFFIC-GEN Server,Client Add +ress = 192.0.0.6 1, ,[1024], Application,TRAFFIC-GEN Server,Session St +art Time (s) = 0.226811597 1, ,[1024], Application,TRAFFIC-GEN Server,Session En +d Time (s) = 19.909754409 1, ,[1024], Application,TRAFFIC-GEN Server,Session St +atus = Closed 1, ,[1024], Application,TRAFFIC-GEN Server,Total byte +s Received = 8320 1, ,[1024], Application,TRAFFIC-GEN Server,Total Data + Units Received = 260 1, ,[1024], Application,TRAFFIC-GEN Server,Throughput + (bits/s) = 3381 1, ,[1024], Application,TRAFFIC-GEN Server,Average En +d-to-End Delay (s) = 0.026102975 1, ,[1024], Application,TRAFFIC-GEN Server,Average Ji +tter (s) = 0.070900925 1, ,[1024], Application,TRAFFIC-GEN Server,Client Add +ress = 192.0.0.4 1, ,[1024], Application,TRAFFIC-GEN Server,Session St +art Time (s) = 0.107537260 1, ,[1024], Application,TRAFFIC-GEN Server,Session En +d Time (s) = 19.984968334 1, ,[1024], Application,TRAFFIC-GEN Server,Session St +atus = Closed 1, ,[1024], Application,TRAFFIC-GEN Server,Total byte +s Received = 11232 1, ,[1024], Application,TRAFFIC-GEN Server,Total Data + Units Received = 351 1, ,[1024], Application,TRAFFIC-GEN Server,Throughput + (bits/s) = 4520 1, ,[1024], Application,TRAFFIC-GEN Server,Average En +d-to-End Delay (s) = 0.020293675 1, ,[1024], Application,TRAFFIC-GEN Server,Average Ji +tter (s) = 0.056769093 1, ,[1024], Application,TRAFFIC-GEN Server,Client Add +ress = 192.0.0.5 1, ,[1024], Application,TRAFFIC-GEN Server,Session St +art Time (s) = 0.058634166 1, ,[1024], Application,TRAFFIC-GEN Server,Session En +d Time (s) = 19.798208565 1, ,[1024], Application,TRAFFIC-GEN Server,Session St +atus = Closed 1, ,[1024], Application,TRAFFIC-GEN Server,Total byte +s Received = 6624 1, ,[1024], Application,TRAFFIC-GEN Server,Total Data + Units Received = 207 1, ,[1024], Application,TRAFFIC-GEN Server,Throughput + (bits/s) = 2684 1, ,[1024], Application,TRAFFIC-GEN Server,Average En +d-to-End Delay (s) = 0.026288118 1, ,[1024], Application,TRAFFIC-GEN Server,Average Ji +tter (s) = 0.090685171 1, ,[1024], Application,TRAFFIC-GEN Server,Client Add +ress = 192.0.0.2 1, ,[1024], Application,TRAFFIC-GEN Server,Session St +art Time (s) = 0.028508654 1, ,[1024], Application,TRAFFIC-GEN Server,Session En +d Time (s) = 19.981800333 1, ,[1024], Application,TRAFFIC-GEN Server,Session St +atus = Closed 1, ,[1024], Application,TRAFFIC-GEN Server,Total byte +s Received = 12832 1, ,[1024], Application,TRAFFIC-GEN Server,Total Data + Units Received = 401 1, ,[1024], Application,TRAFFIC-GEN Server,Throughput + (bits/s) = 5144 1, ,[1024], Application,TRAFFIC-GEN Server,Average En +d-to-End Delay (s) = 0.009312223 1, ,[1024], Application,TRAFFIC-GEN Server,Average Ji +tter (s) = 0.046495978 1, ,[1024], Application,TRAFFIC-GEN Server,Client Add +ress = 192.0.0.3 1, ,[1024], Application,TRAFFIC-GEN Server,Session St +art Time (s) = 0.017999448 1, ,[1024], Application,TRAFFIC-GEN Server,Session En +d Time (s) = 19.943126887 1, ,[1024], Application,TRAFFIC-GEN Server,Session St +atus = Closed 1, ,[1024], Application,TRAFFIC-GEN Server,Total byte +s Received = 10880 1, ,[1024], Application,TRAFFIC-GEN Server,Total Data + Units Received = 340 1, ,[1024], Application,TRAFFIC-GEN Server,Throughput + (bits/s) = 4368 1, ,[1024], Application,TRAFFIC-GEN Server,Average En +d-to-End Delay (s) = 0.019138684 1, ,[1024], Application,TRAFFIC-GEN Server,Average Ji +tter (s) = 0.060386082 2, , [0], Physical, 802_15_4,Signals transmitte +d = 1571 2, , [0], Physical, 802_15_4,Signals detected = + 1732 2, , [0], Physical, 802_15_4,Signals locked on +by PHY = 1191 </readmore> <code>
but it is printing only that last addresses and the corresponding data packets received: that is 3 and 340. I am new to regular expressions and perl in general. Kindly help ! Thanks in advance :)open(STATFILE,$statfile) or die ("could not open the stat file"); my $lines = do { local $/; <STATFILE> }; my @ones; my @twos; while($lines =~ m/traffic-gen.*client address = 192\.0\.0\.(\d+).* +data units received = (\d+).*jitter/scgi) { print $1, "\tyes\t",$2,"\n"; push @ones, $1; push @twos, $2; } print @ones,@twos;
In reply to multiple regexp matches in multi line string by wirelesscharlie
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |