I'm struggling with trying to capture multiple matches within a group of lines in a text file.
The data takes on a bunch of forms like
AO22_X1N_A9PP96CTS_C24 SYN_INC_187 ( .A0 ( test_so6 ) , .A1 ( n2218 ) , .B0 ( U_PAUSEdata_ff_int_28_ ) , .B1 ( n2 ) , .Y ( n2597 ) ) ;
NAND3_X1R_A9PP96CTUL_C16 SYN_INC_154 ( .A ( n1563 ) , .B ( U_PAUSEwcnt ) , .C ( n1640 ) , .Y ( n1467 ) ) ;
The first piece is a name. Might want tat later but for now I am interested in the ports ex .A ( net ) Ideally I want to capture all the input net names (those with A,B,C,D etc) and the single output .Y ( net)
Eventually I want to store them into a hash where the output net is the key and the data is a ref to the array of inputs but for now I'm just trying to get all the input nets to be captured.
This is what I'm currently working with
open (FILE, "<maca") or die("Can not open $file");
while (defined(my $cur_line = <FILE>)) {
if ($cur_line =~ m/[A-Z].*?\.[A-C]\d* \( (.*?) \).*?;/mg) {
print "THIS gate $cur_line $1 $2 $3\n";
}
}
I'm trying for this display
THIS gate NAND3_X1R_A9PP96CTUL_C16 SYN_INC_154 ( .A ( n1563 ) , .B ( U_PAUSEwcnt ) , .C ( n1640 ) , .Y ( n1467 ) ) ;
n1563 U_PAUSEwcnt n1640
But I get this. Actually I don't care about the first line just the 2nd. The first is for debugging. I thought the m would search multiple lines and the g would globally match the multi line string. What am I missing
THIS gate .B ( U_PAUSEwcnt ) , .C ( n1640 ) , .Y ( n1467 ) ) ;
n1640