Hello Chia

Using the ... range operator appears to do what you want, if I understand correctly;

open(FILE,"input.txt");

while (<FILE>){

 print if !(/^\.SUBCKT (\S\S)/ ... /^\.ends $1/);

}

This print lines that don't fall between lines that match the two patterns

My test file input.txt was like this;

.SUBCKT AA
1
2
3
4
5
.ends AA

abc

.SUBCKT BB
1
2
3
4
5
.ends BB
DEF
.SUBCKT AA
1
2
3
4
5
.ends AA

ghi

.SUBCKT BB
1
2
3
4
5
.ends BB

jkl

.SUBCKT AA
1
2
3
4
5
.ends AA
xxxx
.SUBCKT BB
1
2
3
4
5
.ends BB

yyyyy

The output using the above file as input was

abc

DEF

ghi


jkl

xxxx

yyyyy


Hope this help

Best wishes

Reg

> Subject: line editing
> Date: Wed, 19 Sep 2001 09:30:14 -0700
> From: "Chia Teng" <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
>
> I have a huge file containing the following patterns to be deleted:
>
> .SUBCKT AA
> 5 lines
> .ends AA
>
> .SUBCKT BB
> 6 lines
> .ends BB
>     .
>     .
>     .
> In vi it's easy to "search and delete" them. e.g. by
> /^\.SUBCKT AA/;/^\.ends AA/d
>
> Is there a better way to do this in perl ?
>
> _________________________________________________________________



---------------------------------------------------------------------
 
 E-mail Confidentiality Notice and Disclaimer
 
  This email and any files transmitted with it are confidential and are intended 
solely for the use of the individual or entity to which they are addressed. Access to 
this e-mail by anyone else is unauthorised. If you are not the intended recipient, any 
disclosure, copying, distribution or any action taken or omitted to be taken in 
reliance on it, is prohibited. 
  E-mail messages are not necessarily secure.  Hitachi does not accept responsibility 
for any changes made to this message after it was sent. 
  Please note that Hitachi checks outgoing e-mail messages for the presence of 
computer viruses.
 
---------------------------------------------------------------------

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

Reply via email to