Thats really neat way of writing the expression I was looking for.
But somehow I couldnt get the following compiled. It says
Search pattern not terminated at ./a.pl line 8
1 #!/usr/bin/perl 2 3 use warnings; 4 use strict; 5 6 7 my $a="1: 192.168.0.180:32866 - 192.168.0.183:143 (a2b) 14< (complete)"; 8 my $ip = ((?:\d{1,3}\.){3}\.\d{1,3}); 9 10 if($a ~= /($ip)/) { 11 print "ip = $1\n"; 12 } 13
A simple expression assigned to $ip works though. E.g. $ip = [0-9] But as I try to make the regex complex i run into syntax problems.
Thanks and Regards, Manish
On 05/17/2005 07:54 PM, Ing. Branislav Gerzo wrote:
Manish Sapariya [MS], on Tuesday, May 17, 2005 at 17:38 (+0530) has on mind:
MS> echo "1: 192.168.0.180:32866 - 192.168.0.183:143 (a2b) MS> 17> 14< (complete)" | perl -lane 'print$_;if($_ =~ MS> /(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}):(\d{1,5}) - MS> (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}):(\d{1,5})/) {print "Source IP MS> = $1, Source Port = $2, Destinatin IP = $3, Destination Port = MS> $4\n"}'
some ideas how to write ip: ((?:\d{1,3}\.){3}\.\d{1,3}) (\d{1,3}(?:\.\d{1,3}){3})
good idea is store regexp into variable and use that variable in regexp. $ip = ((?:\d{1,3}\.){3}\.\d{1,3}) /$ip:(\d{1,3})\s*-\s*$ip:(\d{1,3})/ of course you can do that with port too.
--
How do you protect mail on web? I use http://www.2pu.net
[A revolving lithic conglomerate accrues no lichen.]
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>