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
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/){
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
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.
>
>
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
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
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
> 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
> > > @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
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
[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
> 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
);
/(\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
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) ;
>
";
-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
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) ;
16 matches
Mail list logo