in reply to $variable as regex in s///

Your code worked for me. Maybe there was a typo in the version you actually ran?

Phil