$BIG_REGEX = " ... "; sub do_something { # The expression is "fixed" into place on first use. # !! Its a constant. if ( $sexpert =~ m/$BIG_REGEX/o) { ... } } do_something(); # the expression is compiled and fixed into place do_something(); # the compiled expression is directly re-used