I think you want something like this (or some derivation)...

while (<DATA>) {
  if( /DisplayName(.*)/ ) {
    print $_; # print the full line
    $mytext = $1; # assign trapped text
  }
}

Rob

-----Original Message-----
From: Allison Ogle [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 11, 2002 2:29 PM
To: [EMAIL PROTECTED]
Subject: Assigning part of a string to a variable using the filehandle.


Hi,

I have a problem trying to assign part of a string to a variable using the
filehandle.  For example, if the string was DisplayName  =XYZ and I want to
assign XYZ to the variable $mytext in the code below how would I do this.  I
am having trouble with the line ($mytext) =(<DATA>)=~ /DisplayName(.*)/; and
I know this is wrong but I can't find any documentation anywhere on how to
do this.  Any help would be great!

while(<DATA>){
        print if/DisplayName/;          # prints the line if it conains
'DisplayName'
        if(/DisplayName/){
                ($mytext) =(<DATA>)=~ /DisplayName(.*)/;
                print $mytext;
        }


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

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

Reply via email to