The difference is context. In scalar context, a regex usually returns the number of matches or the number of substitutions, which is not what you want here. Adding parentheses creates a list context in which a regex will usually return something closer to what you want here.