Sorry,I really didn't know this regex written by John:

/^User:\s*(.+?)$(?=.*=([^[]+)\[)/sm;

Can anyone explain for that?thanks.

2005/11/17, Jeff Pang <[EMAIL PROTECTED]>:
> Sorry,I can't  understand for this RE too.John explain that pls.
>
> 2005/11/17, S, karthik (IE03x) <[EMAIL PROTECTED]>:
> > John and Jeff,
> >
> > Could you please explain the RE used.
> >
> > /^User:\s*(.+?)$(?=.*=([^[]+)\[)/sm;
> >
> > I understood that it looks for 'User:\s'. Then I am not able to figure
> > out the meaning of the remaining part of RE.
> >
> >
> > With Best Regards,
> >
> > Karthikeyan S
> >
> >
> >
> > -----Original Message-----
> > From: Jeff Pang [mailto:[EMAIL PROTECTED]
> > Sent: Thursday, November 17, 2005 2:06 PM
> > To: John W. Krahn
> > Cc: Perl Beginners
> > Subject: Re: How to get this hash?
> >
> > Thanks for John.I have tested it,it is good for me.
> >
> > 2005/11/17, John W. Krahn <[EMAIL PROTECTED]>:
> > > Jeff Pang wrote:
> > > > Hi,lists,
> > >
> > > Hello,
> > >
> > > > I have a file that look as:
> > > >
> > > > --
> > > > User: honorhr40
> > > > Got data from YY23 (md1=23,md2=24):
> > > > [0] xxxx=46[I:0 T:Int]
> > > > [1] pd=[I:0 T:Str]
> > > > [2] cosnm=normal[I:0 T:Str]
> > > > --
> > > > User: lulu-918
> > > > Got data from YY18 (md1=18,md2=19):
> > > > [0] xxxx=69[I:0 T:Int]
> > > > [1] pd=back.zzz.com[I:0 T:Str]
> > > > [2] cosnm=normal[I:0 T:Str]
> > > >
> > > > ......
> > > >
> > > > and thousands of these lines.
> > > >
> > > > I want to get the No.1 line and No.5 line,just as:
> > > >
> > > > User: honorhr40
> > > > [2] cosnm=normal[I:0 T:Str]
> > > >
> > > > and put the two lines into a hash,as:
> > > >
> > > > $hash{'honorhr40'} = 'normal';
> > > >
> > > > I have no ideas on doing this work.Can you anyone give me some
> > help?thanks.
> > >
> > > This appears to do what you want:
> > >
> > > #!/usr/bin/perl
> > > use warnings;
> > > use strict;
> > > use Data::Dumper;
> > >
> > > $/ = "--\n";
> > >
> > > my %hash;
> > >
> > > while ( <DATA> ) {
> > >
> > >    next unless /^User:\s*(.+?)$(?=.*=([^[]+)\[)/sm;
> > >
> > >    $hash{ $1 } = $2
> > >    }
> > >
> > > print Dumper \%hash;
> > >
> > > __DATA__
> > >
> > > --
> > > User: honorhr40
> > > Got data from YY23 (md1=23,md2=24):
> > > [0] xxxx=46[I:0 T:Int]
> > > [1] pd=[I:0 T:Str]
> > > [2] cosnm=normal[I:0 T:Str]
> > > --
> > > User: lulu-918
> > > Got data from YY18 (md1=18,md2=19):
> > > [0] xxxx=69[I:0 T:Int]
> > > [1] pd=back.zzz.com[I:0 T:Str]
> > > [2] cosnm=normal[I:0 T:Str]
> > >
> > >
> > >
> > > 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>
> >
> >
> >
>

--
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