"Anish Kumar K." <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> > ----- Original Message -----
> > From: "Anish Kumar K." <[EMAIL PROTECTED]>
> >
> > Hi
> >
> > Suppose this is the line
> > after_click_color = cc6600
> >
> >
> > if I use
> > @recField=split(/=/,$_);
> >
> > I will get
> >
> > $recField[0] as after_click_color
> > and
> > $recField[1] as cc6600
> >
> > If there is space before/after = that will also be involved..What if
I
> don;t
> > wanted the space..I wanted to trim out the spaces before and after =

> ----- Original Message -----
> From: "Michael David" <[EMAIL PROTECTED]>
>
> > Try this....
> >
> > @recField = split /\s*=\s*/, $_;

> Yes thanks it is working fine in cases where there is space
before/after =
>
> But what if there is space before and after varable name, i.e
>
>                   after_click_color                           =
> cc6600
>
> in this case I do it will fail...
>  I need the output as
> $recField[0] as after_click_color
> $recField[1] as cc6600

At this point, I'm wondering if you might be better off using m//
instead of split():

@recField = m/(\S+)\s*=\s*(\S+)/;

That will capture any two non-whitespace fields, seperated by (possible
space and) an equals sign.  It will ignore any whitespace at the
beginning or end of the original string.

Paul Lalli




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