in reply to returning variable from within regex

Can you maybe give an example of the data you're trying to match and the expected results? It's sounds like you want
elsif($var1=~ /[$var2]([a-z])/) { #stuff with $1 }

but it's hard to say.