RE: Parsing a line

2002-04-23 Thread Timothy Johnson
Well, if you've already got a variable with the program name that you're using, why not something like this: $Start .= " Parm1 Parm2"; (assuming that you are not using the variable $Start for anything else) Otherwise you can do: $newvar = $Start." Parm1 Parm2"; -Original Message- From

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

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

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

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