Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[Perl] Problem in string comparison

Status
Not open for further replies.

maulin sheth

Advanced Member level 2
Advanced Member level 2
Joined
Oct 24, 2010
Messages
502
Helped
90
Reputation
179
Reaction score
90
Trophy points
1,318
Location
Bangalore, India
Visit site
Activity points
4,161
Hello All,

I have a text file like :
"IN" = IN_0[0..3]+IN_1[5...7];
"OUT" = OUT_0[2..5] + OUT_1;

Now I am trying the grep IN_1[5..7] but I am not able to grep only IN_1[5..7] string..
Script is like :

$pattern = "IN_1[5..7]";
for(@full_test_file)
{
if($file[$i] =~ m/$pattern/)
{
print "matched";
}
}

The main problem is it matches only IN_1 not IN_1[5..7],
I want solution rather than doing this: $pattern = 'IN_1\[5\.\.7\]'

Any other solution?

BR,
Maulin Sheth
 

to escape meta characters:
if($file[$i] =~ m/\Q$pattern\E/)
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top