If the file is fixed in this format, then you could do a check for 

   )

and write the line after that is found. Then continue with the file. For
example

open IN, "c:/input.txt" || die "Can't open c:/input.txt: $!";
open OUT, ">c:/new.txt" || die "Can't create c:/new.txt: $!";

while (<IN>) {
        if (/\s+)/) { # One or more spaces followed by a right bracket
                # The line has been found, so print it out and add the
desired text to the new file
                print OUT;
                print OUT "ABC = 1.1\n";
        } else {
                print OUT;
        }
}

close IN;
close OUT;

You may need to escape the right bracket in the regex. So it looks like
this:

/\s+\)/

I haven't tested it.

HTH

John

-----Original Message-----
From: pn [mailto:[EMAIL PROTECTED]]
Sent: 31 January 2002 14:05
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Modifying/Additng text in a file


I have a file whose contents are of the form :

NET_A OUTPUT (
   REQUIRED (
      _UP %0.093 BR CLK
      _DN %0.093 BR CLK
   )
)

NET_B OUTPUT (
   REQUIRED (
      _UP %0.093 BR CLK
      _DN %0.093 BR CLK
   )
)


I would like to read in this file in and modify the
contents to be as follows :

NET_A OUTPUT (
   REQUIRED (
      _UP %0.093 BR CLK
      _DN %0.093 BR CLK
   )

ABC = 1.1            // Insert this expression
)

NET_B OUTPUT (
   REQUIRED (
      _UP %0.093 BR CLK
      _DN %0.093 BR CLK
   )
ABC = 1.1          //  Insert this expression
)

Any pointer on how to accomplish this would be greatly
appreciated. Could this be accomplished by using a
regexp ?

Thanks

PN



__________________________________________________
Do You Yahoo!?
Great stuff seeking new owners in Yahoo! Auctions! 
http://auctions.yahoo.com

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


--------------------------Confidentiality--------------------------.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.



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

Reply via email to