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
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
> 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
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) ;
>
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
12 matches
Mail list logo