develooper Front page | perl.beginners | Postings from March 2002

If (/start/ .. /end/) Flip Flop Mechanism

Thread Next
From:
Steven M. Klass
Date:
March 2, 2002 10:11
Subject:
If (/start/ .. /end/) Flip Flop Mechanism
Message ID:
200203021810.g22IAuc21695@vivids1.nsc.com
Hi all

	I know there is a flip flop option but I'm not sure thats what I need..  
Here is what I want to do - and I have no idea how to do this.

Basically I have a section of text that I am doing a search and replace 
operation.  The problem is what if the search text doesn't exist - I still 
want to add it.

So the logic is if it exists in the region replace it, if you can't find it 
add to to it

if (/start/ .. /end/){
   s/^foo/bar/;

}
now what if foo didn't exist - bar still should be set!

Any ideas?

-- 

 Steven M. Klass
 Physical Design Manager

 National Semiconductor Corp
 7400 W. Detroit Street
 Suite 170
 Chandler AZ 85226

 Ph:480-753-2503
 Fax:480-705-6407

 steven.klass@nsc.com
 http://www.nsc.com


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About