Re: help about regex matching

2005-11-29 Thread Jeff Pang
oh,I see it finally.Thanks for everyone! 2005/11/29, John W. Krahn <[EMAIL PROTECTED]>: > Jeff Pang wrote: > > yes,John's code work well too.But I still don't know why this code > > can't run correctly: > > > > next unless /(\S+).*(\d+\.\d+\.\d+\.\d+)/s; > > > > When I run it,I get these results:

Re: help about regex matching

2005-11-29 Thread John W. Krahn
Jeff Pang wrote: > yes,John's code work well too.But I still don't know why this code > can't run correctly: > > next unless /(\S+).*(\d+\.\d+\.\d+\.\d+)/s; > > When I run it,I get these results: > > 364 2.168.2.20 > 286.4 2.168.2.21 > 264.4 2.168.2.22 > 138 2.168.2.23 > 562.3 2.16

RE: help about regex matching

2005-11-29 Thread Charles K. Clarkson
Pant, Hridyesh wrote: : Why are u using this. : local $/ = "\n\n"; Because I'm cocky! :) $/ is a special perl variable which is used to define the input record separator. It is set to "\n" as a default. By resetting it to "\n\n", I was able to get two lines at

RE: help about regex matching

2005-11-29 Thread Pant, Hridyesh
Why are u using this. local $/ = "\n\n"; -Original Message- From: Charles K. Clarkson [mailto:[EMAIL PROTECTED] Sent: 29 November 2005 13:43 To: 'Perl Beginners' Subject: RE: help about regex matching Jeff Pang <mailto:[EMAIL PROTECTED]> wrote: : Thanks

Re: help about regex matching

2005-11-29 Thread Jeff Pang
yes,John's code work well too.But I still don't know why this code can't run correctly: next unless /(\S+).*(\d+\.\d+\.\d+\.\d+)/s; When I run it,I get these results: 364 2.168.2.20 286.4 2.168.2.21 264.4 2.168.2.22 138 2.168.2.23 562.3 2.168.2.24 80.72.168.2.25 355 2.168.2

Re: help about regex matching

2005-11-29 Thread John W. Krahn
Jeff Pang wrote: > hi,list, Hello, > I have a file looking as below: > > 356.5 > 192.168.2.20 > > [snip] > > 612 > 192.168.2.31 > > ... > > > I want to get this result: > > 356.5 192.168.2.20 > 283.3 192.168.2.21 > 261.9 192.168.2.22 > ... > > > and,I write this regex for matching: > >

Re: help about regex matching

2005-11-29 Thread Jeff Pang
It's ok now.Thanks very much. 2005/11/29, Charles K. Clarkson <[EMAIL PROTECTED]>: > Jeff Pang wrote: > > : Thanks for Charles.That code can work well,but I still want > : to know how to do it with regex expression. > > use strict; > use warnings; > > local $/ = "\n\n";

RE: help about regex matching

2005-11-29 Thread Charles K. Clarkson
Jeff Pang wrote: : Thanks for Charles.That code can work well,but I still want : to know how to do it with regex expression. use strict; use warnings; local $/ = "\n\n"; while ( ) { chomp; printf "%-5s% 15s\n", /(.+)\n(.+)/; } __END__ HTH, Charles K. Clark

Re: help about regex matching

2005-11-28 Thread Jeff Pang
Thanks for Charles.That code can work well,but I still want to know how to do it with regex expression. 2005/11/29, Charles K. Clarkson <[EMAIL PROTECTED]>: > Jeff Pang wrote: > : I would like to use regex for my destination because the file > : size is large and having

RE: help about regex matching

2005-11-28 Thread Bedanta Bordoloi, Gurgaon
Hi Jeff, Here's a solution u can have a look at: open(INPUTFILE, "d:/data.log"); open(OUTPUTFILE, ">d:/output.log"); my $last_str = "INIT"; RECORD: while(){ chomp; $str = $_; if ($last_str ne "INIT" && length($str) != 0){ print OUTPUTFILE "$last_str $str\n"

RE: help about regex matching

2005-11-28 Thread Charles K. Clarkson
Jeff Pang wrote: : I would like to use regex for my destination because the file : size is large and having much lines. An unnecessary regex would slow you down on a large file. HTH, Charles K. Clarkson -- Mobile Homes Specialist 254 968-8328 No regex needed

Re: help about regex matching

2005-11-28 Thread Jeff Pang
I would like to use regex for my destination because the file size is large and having much lines.Thanks for Bhate's reply. 2005/11/29, Dhanashri Bhate <[EMAIL PROTECTED]>: > Hi Jeff, > If that the problem definition, why do you need regex? You can just keep on > reading the lines one by one and c

RE: help about regex matching

2005-11-28 Thread Dhanashri Bhate
Hi Jeff, If that the problem definition, why do you need regex? You can just keep on reading the lines one by one and combine 1st and 2nd, 3rd and 4th and so on.. I hope I got your question correct :) Thanks and regards, Dhanashri Life is a differ