$inverse_regex = 'a.b'; for (0..9,a..z){ ($result = $inverse_regex) =~ s/\./$_/; print $result; }