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.7    2.168.2.25
355     2.168.2.26
266.5   2.168.2.27
327     2.168.2.28


somethings as '19' have lost.

2005/11/29, John W. Krahn <[EMAIL PROTECTED]>:
> 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:
> >
> > {
> >     local $/="";
> >     while (<FILE>)
> >     {
> >         next unless /^(.+?)$(?=.*(\d+\.\d+\.\d+\.\d+))/sm;
> >         print $1,"\t",$2,"\n";
> >     }
> > }
> >
> > but it can't work correctly.
> > So,I want to know how to adjust this regex?Thanks.
>
> Probably something like this:
>
> {
>    local $/ = '';
>    while ( <FILE> )
>    {
>        next unless /(\S+)\s+(\d+\.\d+\.\d+\.\d+)/;
>        print "$1\t$2\n";
>    }
> }
>
>
>
> John
> --
> use Perl;
> program
> fulfillment
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>
>

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to