alabamajack
alabamajack

Reputation: 662

Connect a expression and a variable in a regex

I want to do something like this

 if($variable =~ /$other_variable_expression/){
     do something;
 }

where $other_variable is a dynamic part(changed by a loop etc.) and expression is a static part like "abc" always!

How to do?

Upvotes: 1

Views: 40

Answers (1)

ysth
ysth

Reputation: 98398

Two ways:

/${other_variable}_expression/

or

/$other_variable\_expression/

Upvotes: 5

Related Questions