in reply to Variable in regexp

Another way is to use whitespace in the regex with the //x modifier (perlre)
/ $var _ /x

Replies are listed 'Best First'.
Re^2: Variable in regexp
by JavaFan (Canon) on Mar 22, 2011 at 01:33 UTC
    The disadvantage is that that only works in patterns. The ${var}_ method also works in double quoted strings.