例如:将M28(net112innnet036agnd)n33w=4ul=500.0nm=2M29(net108inpnet036agnd)n33w=4ul=500.0n...
例如:
将
M28 (net112 inn net036 agnd) n33 w=4u l=500.0n m=2
M29 (net108 inp net036 agnd) n33 w=4u l=500.0n m=2
M30 (net036 vs agnd agnd) n33 w=2u l=1u m=4
M27 (net125 vs agnd agnd) n33 w=2u l=2u m=2
M25 (net121 vs agnd agnd) n33 w=2u l=2u m=2
插入到
I19 (AGND AVDD vb_4 net0123 vb_2 vb_3) bias
I12 (AGND AVDD vb_4 net0123 vb_2 vb_4) bias
形式如下:
I19 (AGND AVDD vb_4 net0123 vb_2 vb_3) bias
M28 (net112 inn net036 agnd) n33 w=4u l=500.0n m=2
M29 (net108 inp net036 agnd) n33 w=4u l=500.0n m=2
M30 (net036 vs agnd agnd) n33 w=2u l=1u m=4
M27 (net125 vs agnd agnd) n33 w=2u l=2u m=2
M25 (net121 vs agnd agnd) n33 w=2u l=2u m=2
I12 (AGND AVDD vb_4 net0123 vb_2 vb_4) bias
M28 (net112 inn net036 agnd) n33 w=4u l=500.0n m=2
M29 (net108 inp net036 agnd) n33 w=4u l=500.0n m=2
M30 (net036 vs agnd agnd) n33 w=2u l=1u m=4
M27 (net125 vs agnd agnd) n33 w=2u l=2u m=2
M25 (net121 vs agnd agnd) n33 w=2u l=2u m=2
#!/usr/bin/perl
#t.pl
open A,"txt1"; #一段文本
my @a1=(<A>);
while(<>){ #插入文本
if (/I(19|12)/){print $_,"@a1";}
else {print $_}
}
===============
perl t.pl txt2
I19 (AGND AVDD vb_4 net0123 vb_2 vb_3) bias
M28 (net112 inn net036 agnd) n33 w=4u l=500.0n m=2
M29 (net108 inp net036 agnd) n33 w=4u l=500.0n m=2
M30 (net036 vs agnd agnd) n33 w=2u l=1u m=4
M27 (net125 vs agnd agnd) n33 w=2u l=2u m=2
M25 (net121 vs agnd agnd) n33 w=2u l=2u m=2
I12 (AGND AVDD vb_4 net0123 vb_2 vb_4) bias
M28 (net112 inn net036 agnd) n33 w=4u l=500.0n m=2
M29 (net108 inp net036 agnd) n33 w=4u l=500.0n m=2
M30 (net036 vs agnd agnd) n33 w=2u l=1u m=4
M27 (net125 vs agnd agnd) n33 w=2u l=2u m=2
M25 (net121 vs agnd agnd) n33 w=2u l=2u m=2
例如:
subckt op2 XXXXXXX
M28 (net112 inn net036 agnd) n33 w=4u l=500.0n m=2
M29 (net108 inp net036 agnd) n33 w=4u l=500.0n m=2
M30 (net036 vs agnd agnd) n33 w=2u l=1u m=4
M27 (net125 vs agnd agnd) n33 w=2u l=2u m=2
M25 (net121 vs agnd agnd) n33 w=2u l=2u m=2
ends op2
首先提取 MM开头的文本,然后插入到I开头的语句后面,请问用perl如何实现?谢谢!!
-----------------------------------------------------------------------------
继续回答
open T,"txt2";
my @a2=grep/^\s*M/,; #提取 MM开头的文本
ubckt op2 XXXXXXX
M30 (net036 vs agnd agnd) n33 w=2u l=1u m=4
M27 (net125 vs agnd agnd) n33 w=2u l=2u m=2
M25 (net121 vs agnd agnd) n33 w=2u l=2u m=2
ends op2
I12 (AGND AVDD vb_4 net0123 vb_2 vb_4) op2
当ends后面的字符串和I开头的语句最后一个字符串相同时,才进行楼上那样的插入,请问如何实现?谢谢!!!
ubckt op2 XXXXXXX
M30 (net036 vs agnd agnd) n33 w=2u l=1u m=4
M27 (net125 vs agnd agnd) n33 w=2u l=2u m=2
M25 (net121 vs agnd agnd) n33 w=2u l=2u m=2
ends op2
I12 (AGND AVDD vb_4 net0123 vb_2 vb_4) op2
2文本 OR 1文本??
txt1
ubckt op2 XXXXXXX
M30 (net036 vs agnd agnd) n33 w=2u l=1u m=4
M27 (net125 vs agnd agnd) n33 w=2u l=2u m=2
M25 (net121 vs agnd agnd) n33 w=2u l=2u m=2
ends op2
txt2
I12 (AGND AVDD vb_4 net0123 vb_2 vb_4) op2
谢谢!!!
本回答被网友采纳