No more -no_match_vars

The English module translates Perl’s cryptic variable names to English equivalents. For instance, $_ becomes $ARG. This means that the match variable $& becomes $MATCH. This also means that using the English module triggered the performance issue associated with the match variables $`, $&, and $' even if you didn’t use those variables yourself—the module used them for you. The Devel::NYTProf debugger had a sawampersand feature to tell you one of those variables appeared in the code. We covered this in Item 33. Watch out for the match variables.

The English module uses typeglob assignments to do its work (something I cover in Mastering Perl). The code looks like:

# The ground of all being.

	*ARG                        = *_	;

# Matching.

	*LAST_PAREN_MATCH           = *+	;
	*LAST_SUBMATCH_RESULT       = *^N ;
	*LAST_MATCH_START           = *-{ARRAY} ;
	*LAST_MATCH_END             = *+{ARRAY} ;

The module skips those match variables if you specify -no_match_vars as part of the import list:

use English qw(-no_match_vars);

Perl v5.17.7 re-engineered internal strings with a new copy-on-write system. Since it doesn’t have to copy a string into $& every time it makes a match, you don’t get the performance penalty. This also means that you don’t need to pass around strings by reference just to prevent a copy.