Actually, the content of the file looks something like:-
name=john
id=12345
password=12345
colour=blue

I am trying to grab the value field of each line and assigned it to be a
variable.

I tried the regular expressions, but seems like the syntax is wrong or
something,

@file = <filehandle>; #small file anyway

$file[0] is equal to 'name=john'  but i just wanna extract john to be my
scalar variable.

like print $name but returns john only and the same extraction method for
the rest of the other 3 fields as well.

kindly advice!... million thanks!




----- Original Message -----
From: "David Gray" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Cc: "'ChaoZ InferNo'" <[EMAIL PROTECTED]>; "'Shawn'" <[EMAIL PROTECTED]>
Sent: Friday, May 17, 2002 10:16 PM
Subject: RE: regular expression


> > <code>
> ...
> > for(@text) {
> >   /(d+)$/; # Match only the numbers at the end of the string
>      ^^
>       this should actually be (\d+)
>
> I would actually conditionally print also, like so:
>
>  print $1 if /(\d+)$/;
>
> And depending on the size of the file, instead of reading the whole
> thing into memory with
>
>  my @text = (<FILE>);
>
> I would do:
>
>  while(<FILE>) {
>    print $1 if /(\d+)$/;
>  }
>
> >            # and store them in '$1' to be printed out on the
> >            # next line followed by a new line character
> ...
> > > @text # contains values of a phone directory
> > > $text[0] contains john=012345678
> > >
> > > $phone1 = ?
> > >
> > > let say i wanted to grab just the values'012345678'.
> > > how should i go on truncating the values?
>
> Cheers,
>
>  -dave
>
>
>

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to