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. Continue reading “No more -no_match_vars”

Perl v5.18 adds character class set operations

Perl v5.18 added experimental character code set operations, a requirement for full Unicode support according to Unicode Technical Standard #18, which specifies what a compliant language must support and divides those into three levels.

The perlunicode documentation lists each requirement and its status in Perl. Besides some regular expression anchors handling all forms of line boundaries (which might break older programs), set subtraction and intersection in character classes was the last feature Perl needed to be Level 1 compliant. Continue reading “Perl v5.18 adds character class set operations”

Don’t use named lexical subroutines

Lexical subroutines are a stable feature starting with v5.26

Perl v5.18 allows you to define named subroutines that exist only in the current lexical scope. These act (almost) just like the regular named subroutines that you already know about from Learning Perl, but also like the lexical variables that have limited effect. The problem is that the feature is almost irredeemably broken, which you’ll see at the end of this Item. Continue reading “Don’t use named lexical subroutines”

Experimental features now warn (reaching back to v5.10)

Perl 5.18 provides a new way to introduce experimental features in a program, augmenting the feature pragma that v5.10 added. This change marks certain broken v5.10 features as experimental with an eye toward possible removal from the language.

Smart matching in v5.10 led to several broken and conflated features. The given used a lexical version of $_, which broke many other common uses of that variable inside the given, which I explain in Use for() instead of given() and you can see in given/when and lexical $_ …. Continue reading “Experimental features now warn (reaching back to v5.10)”

The vertical tab is part of \s in Perl 5.18

Up to v5.18, the vertical tab wasn’t part of the \s character class shortcut for ASCII whitespace. No one really knows why. It was curious trivia that I pointed out in Know your character classes under different semantics. Whitespace in ASCII, POSIX, and Unicode represented different sets. Perl whitespace was different from POSIX whitespace by only the exclusion of the vertical tab. Now that little oversight is fixed. Continue reading “The vertical tab is part of \s in Perl 5.18”