Re: parsing a line

2007-07-02 Thread Chas Owens
On 7/1/07, alok nath <[EMAIL PROTECTED]> wrote: Hi Chas, Can you please explain the portion ( ([\w ]*\w)\s*= )of the regex.? And why its stored in $s.Can it be directly stored in hash my %rec. Thanks Alok snip First off, the results of the regex are not being stored in $s; the regex is bei

Re: parsing a line

2007-07-01 Thread alok nath
essage From: Chas Owens <[EMAIL PROTECTED]> To: alok nath <[EMAIL PROTECTED]> Cc: beginners@perl.org Sent: Thursday, June 28, 2007 7:45:53 PM Subject: Re: parsing a line On 6/28/07, alok nath <[EMAIL PROTECTED]> wrote: snip > if( $_ =~ m/ID\s=\s"(.*?)"\sDirAbsolute/){

Re: parsing a line

2007-06-28 Thread Chas Owens
On 6/28/07, alok nath <[EMAIL PROTECTED]> wrote: snip if( $_ =~ m/ID\s=\s"(.*?)"\sDirAbsolute/){ snip It does look fragile. A lot depends on how likely the real input matches the example you gave. That regex will break if the input is Note the second space after the "ID =". Also, you can

Re: parsing a line

2007-06-28 Thread alok nath
s <[EMAIL PROTECTED]> To: alok nath <[EMAIL PROTECTED]> Cc: beginners@perl.org Sent: Thursday, June 28, 2007 6:38:09 PM Subject: Re: parsing a line On 6/28/07, alok nath <[EMAIL PROTECTED]> wrote: > Hi, > I am parsing a file which has lines like this. > >

Re: parsing a line

2007-06-28 Thread Chas Owens
On 6/28/07, alok nath <[EMAIL PROTECTED]> wrote: Hi, I am parsing a file which has lines like this. Got stuck up while trying to extract values of fields called Description, ID ? What have you tried? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROT

parsing a line

2007-06-28 Thread alok nath
Hi, I am parsing a file which has lines like this. Got stuck up while trying to extract values of fields called Description, ID ? Pls help. Thanks Alok. Shape Yahoo! in your own image. Join ou

Re: Parsing a line - part 2

2002-04-25 Thread John W. Krahn
David Gray wrote: > > > How about: > > > > /(\S+)=(.+?)(?=\s+\S+=|\s+|\z)/g > > > > > > To catch trailing whitespace at the end of the line of data? > > Actually, I meant: > > /(\S+)=(.+?)(?=\s+\S+=|\s*\z)/g >^^^ Yeah, that will work. :-) J

RE: Parsing a line - part 2

2002-04-25 Thread David Gray
> How about: > > /(\S+)=(.+?)(?=\s+\S+=|\s+|\z)/g > > > To catch trailing whitespace at the end of the line of data? Actually, I meant: /(\S+)=(.+?)(?=\s+\S+=|\s*\z)/g ^^^ -dave -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional

RE: Parsing a line - part 2

2002-04-25 Thread David Gray
> > > @keys{ qw/P ST U SL D/ } = \( $Proc, $Start, $Url, > $Sleep, $Drive ); > > > > This is a shortcut for defining the values of a hash -- it creates > > $keys{P} == $Proc, $keys{ST} == $Start, etc. > > $keys{P} = \$Proc, $keys{ST} = \$Start, etc. Okay... Fair enough. Maybe I'm missing some

Re: Parsing a line - part 2

2002-04-24 Thread John W. Krahn
David Gray wrote: > > > Thank you, John. This code does exactly what I want. Problem > > is, I only understand about 30% of what's going on. I can > > figure out the use of the hash, some of the pattern matching > > & $1/$2. But can someone elaborate on: > > > > @keys{ qw/P ST U SL D/ } = \( $Pro

Re: FW: Parsing a line - part 2

2002-04-24 Thread John W. Krahn
[Please don't top-post] Rich Busse wrote: > > From: John W. Krahn [mailto:[EMAIL PROTECTED]] > > > > Here is one way to do it: > > > > $_ = q[P=IcwRcsm D=D: SL=20 ST=d:\icw\rcsm\StartSv.bat Parm1 Parm2 > > U=http://uslv...]; > > > > my ( $Proc, $Start, $Url, $Sleep, $Drive ); > > my %keys

RE: Parsing a line - part 2

2002-04-24 Thread David Gray
> Thank you, John. This code does exactly what I want. Problem > is, I only understand about 30% of what's going on. I can > figure out the use of the hash, some of the pattern matching > & $1/$2. But can someone elaborate on: > > @keys{ qw/P ST U SL D/ } = \( $Proc, $Start, $Url, $Sleep, $Dri

FW: Parsing a line - part 2

2002-04-24 Thread Busse, Rich
); /(\S+)=(.+?)(?=\s+\S+=|\z)/g ${$keys{uc $1}} = $2; Again, thanks for your time... -Original Message- From: John W. Krahn [mailto:[EMAIL PROTECTED]] Sent: Tuesday, 23 April, 2002 17:39 To: [EMAIL PROTECTED] Subject: Re: Parsing a line Rich Busse wrote: > > I'm currently p

Re: Parsing a line

2002-04-23 Thread John W. Krahn
Rich Busse wrote: > > I'm currently processing lines from an input file this way: > > $_ = "P=IcwRcsm D=D:SL=20 ST=d:\icw\rcsm\StartSv.bat > U=http://uslv..."; > @Token = split ; > foreach (@Token) > { > $Proc = $' if (/P=/i) ; >

RE: Parsing a line

2002-04-23 Thread Timothy Johnson
"; -Original Message- From: Busse, Rich [mailto:[EMAIL PROTECTED]] Sent: Tuesday, April 23, 2002 10:59 AM To: Perl Beginners Subject: Parsing a line I'm currently processing lines from an input file this way: $_ = "P=IcwRcsm D=D:SL=20 ST=d:\icw\rcsm\StartSv.bat U

Parsing a line

2002-04-23 Thread Busse, Rich
I'm currently processing lines from an input file this way: $_ = "P=IcwRcsm D=D:SL=20 ST=d:\icw\rcsm\StartSv.bat U=http://uslv..."; @Token = split ; foreach (@Token) { $Proc = $' if (/P=/i) ; $Start = $' if (/ST=/i) ;