Category Archives: broken feature

No more false postfix lexical declarations in v5.30

Before Perl v5.10 introduced state variables, people did various things to create persistent lexical variables for a subroutine. With v5.30, one of those constructs is now a fatal error. Often you want a persistent variable to be scoped and private to a subroutine. But, once you leave that scope, normal lexical variables disappear because their […]

Lexical $_ and autoderef are gone in v5.24

Two features that I have previously discouraged are now gone from Perl. The lexical $_ and auto dereferencing. The lexical $_ was a consequence of the way Perl wanted smart match to work. In a given-when, instead of aliasing $_ like foreach does, the block had an implicit my $_ = …. This interfered with […]

Perl v5.16 now sets proper magic on lexical $_

[Lexical $_ was removed in v5.24] Perl v5.10 introduced given and the lexical $_. That use of $_, which everyone has assumed is a global variable, turned out to be a huge mistake. The various bookkeeping on the global version didn’t happen with the lexical version, so strange things happened.

Don’t use auto-dereferencing with each or keys

[Update: Perl v5.24 removes this experimental feature, for the reasons I list, among others.] Perl 5.14 added an auto-dereferencing features to the hash and array operators, and I wrote about those in Use array references with the array operators. I’ve never particularly liked that feature, but I don’t have to like everything. Additionally, Perl 5.12 […]

Use for() instead of given()

[Lexical $_ was removed in v5.24] Perl 5.10 introduced the given-when feature, a fancier version of the C switch feature. However, it was poorly designed and tested and depended on two other dubious features, the lexical $_ and smart-matching. Parts of this feature are salvageable, but you should avoid the literal given (and probably the […]