in reply to Regex: return the pattern instead of the actual match

So you want $1 eq $regex? You cannot directly assign to $1, but try this:
if ($_ =~ m/($regex)/ && $regex =~ /(.*)/s) { ... Now $1 will contain $regex ... }
I just cannot figure out why you want this.