Category Archives: 5.20

Perl v5.20 combines multiple my() statements

Perl v5.20 continues to clean up and optimize its internals. Now perl optimizes a series of lexical variable declarations into a single list declaration. You can write them out as separate statements: my( $dog ); my( $cat ); my( $bird ); v5.20 turns that into a single declaration. my( $dog, $cat, $bird ); That doesn’t [...]

In v5.20, -F implies -a implies -n

Perl was once known for its one-liners in its sysadmin heydays. People would pass around lists of these one liners, many of which replaced complicated pipelines that glued together various unix utilities to do some impressive system maintenance. -a splits the input line on whitespace and puts the result in @F -n adds while( ) [...]

Perl 5.20 introduces “Key/Value Slices”

Perl v5.20 adds the “Key/Value Slice”, which extracts multiple keys and their corresponding values from a container (hash or array). It uses the %, which is new, legal syntax for a variable name with subscripts after it: use v5.20; # you don’t need this for the new syntax my %smaller_hash = %big_hash{ @keys }; my [...]

Perl 5.20 optimizes return at the end of a subroutine

Want to save 10 nanoseconds? Perl v5.20 optimizes a return at the end of a subroutine to use two fewer ops in the optimized version. During compilation, a subroutine like this one: sub some_sub { …; return $foo } turns into a subroutine like this one, without the return sub some_sub { …; $foo } [...]

Perl 5.20 uses its own random number generator

Prior to v5.20, perl used whatever random number generator the system provided. This meant that the same program could have statistically different results based on the quality of that function. The rand() for Windows had a max of 32,768 (15 bits), while POSIX has drand48 (48 bits). This sort of numerical un-portability has always been [...]

Perl 5.20 new features

Perl 5.20 is out and there are some nice syntax changes that make life easier for Perlers, along with some improvements that don’t require any work from you. Some of the features are experimental, so be careful that you don’t create problems by overusing them until they settle down. You can download the Perl source [...]