Himi has asked for the wisdom of the Perl Monks concerning the following question:
12-APR-03 12:20:46.902801 IP 10.60.0.114.2684 > 10.60.0.3.110: . ack 3 +927995843 win 0
I need to parse out the source ip , sorce port , destination ip and port.
I have written the following code :
$file = 'testfile'; open(file_info,$file) or die "Can't open $file : $!"; while (<file_info>) { my ( $src_ip, $src_port ) = /IP\s+(\d+\.\d+\.\d+\.\d+)\/(\d+)/; my ( $dst_ip, $dst_port ) = />\s+(\d+\.\d+\.\d+\.\d+)\/(\d+)/; print "$src_ip $src_port $dst_ip $dst_port \n"; } close(file_info)
and this doesnt seem to work.
Please help.
Thanks, Himi
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Need help in perl regexp
by Skeeve (Parson) on Oct 05, 2007 at 09:59 UTC | |
|
Re: Need help in perl regexp
by moritz (Cardinal) on Oct 05, 2007 at 09:49 UTC | |
by Himi (Novice) on Oct 05, 2007 at 10:03 UTC | |
|
Re: Need help in perl regexp
by jeanluca (Deacon) on Oct 05, 2007 at 09:57 UTC | |
|
Re: Need help in perl regexp
by svenXY (Deacon) on Oct 05, 2007 at 10:02 UTC | |
|
Re: Need help in perl regexp
by Himi (Novice) on Oct 05, 2007 at 10:11 UTC |