in reply to Re: Regular Expressions with varialbe with "[]" (Verilog)
in thread Regular Expressions with varialbe with "[]"
Thanks everybody about your kindly reply, following is my code according your replies, and the output which I want :
#!/usr/bin/perl use 5.010; use strict; use warnings; my $port_name = 'sdm_yout_i[1]'; open my $fh, "tt.txt" or die $!; while (<$fh>) { if (/\.([0-9a-z_]*?) \( \{.*?\Q$port_name\E .*?,/) { print '$port_name = ' ; say $port_name; print '$cell name = ' ; say $1; } }
Outputs:
$port_name = sdm_yout_i[1] $cell name = sdm_yout_i
|
|---|