[Melbourne-pm] What's new in Perl 5.18?

Jacinta Richardson jarich at perltraining.com.au
Mon Jun 3 19:36:12 PDT 2013

As announced recently, Perl 5.18 is out.  You might be wondering what 
has changed?  Well yesterday I wrote a Perl tip on all the changes that 
I thought were interesting.  I've included it below.

I'm also running a Programming Perl course in Melbourne in two weeks 
time (17th - 21st June).  I'm currently offering a discount of $500 per 
person, or $750 per person for bookings of 3 or more attendees (for 
bookings made by 3pm Friday 7th).  Contact me for more information.

All the best,


==== What's new in 5.18.0? ====

     Perl 5's yearly release rhythm is well established. Because major
     releases come out every single year, a major release no longer
     introduces a slew of new features. Instead, it consists of a 
smaller set
     of features and bug fixes. Upgrading to a new major version is easier
     than it's ever been.

     On 18th May 2013, Perl 5.18.0 was released.

     What has changed?

==   More information   ==

     In addition to this tip you may find it useful to read
     (http://search.cpan.org/dist/perl-5.18.0/pod/perldelta.pod) the
     perldelta document as well as our earlier tip on
     (http://perltraining.com.au/tips/2012-08-08.html) What's New in
     5.12, 5.14 and 5.16

==   Smart-match, given/when, lexical $_ all moved to experimental   ==

     There's now a new warnings category called "experimental". If you 
use an
     experimental feature without disabling that warning, you'll be told 
     experimental. This allows developers to introduce new ideas and see
     whether they end up with unexpected consequences. Things that work will
     be removed from being experimental in a later release.

     On the other hand, some ideas that have ended up with much confusion
     have been marked as experimental until this confusion is clarified.

     Due to various special-casing, smart-match (and given/when as a 
result) and
     separately, lexical $_ have been marked as experimental. Turn off 
     warnings with the following:

         no warnings "experimental::smartmatch";

         no warnings "experimental::lexical_topic";


         no warnings qw(experimental::smartmatch experimental::lexical_topic);

     The special warnings IDs for each experimental feature, are included
     with their warnings in 
(http://search.cpan.org/dist/perl-5.18.0/pod/perldiag.pod) perldiag.

==   Hash overhaul   ==

     In brief, hash ordering is now actually random for all hashes (as we've
     been told for a long while, but which hasn't always been strictly the
     case). Thus:

         my %hash1 = ( a => 1, b => 2, c => 3);

         my %hash2 = %hash1;

         say join " ", keys %hash1;

         say join " ", keys %hash2;

     would have previously printed out identical key ordering for both 
     during each program run. This will no longer occur.

==   Unicode   ==

     Perl now supports Unicode 6.2.

     You can also define your own names for characters for use in ``\N{}'',
     although if you begin a name with a digit or include commas in the name
     etc, then that's a syntax error.

=    Set operations    =

     You can do set operations (such as intersection) within regular
     expressions character classes, for example:

         no warnings "experimental::regex_sets";

         /(?[ \p{Thai} & \p{Digit} ])/

     will match all the characters that are in the Thai script and are also
     digits. It's experimental, so you may want to turn the warning off.

     Sets can be combined further:

         /(?[ ( \p{Thai} + \p{Lao} ) & \p{Digit} ])

     The union of Thai and Lao scripts intersected with digits gives us all
     digits in Thai and Lao scripts.

     See more at 

==   $^{LAST_FH}   ==

     Should you ever want access to most recently read filename, you can now
     use $^{LAST_FH}

         # read a line from a random (hopefully opened) file handle

         my $string = < $file_handles[ rand @file_hands ] >;

         # oops, too short, let's add another line from that file, too

         if( length $string < MAX_LEN ) {

             $string .= < $^{LAST_FH} >;


==   Lexical subroutine   ==

     It's been possible to create lexical subroutines of a type using
     subroutine references:

         my $sub = sub {




     Now it's possible (experimentally) to create lexical, shared and static
     subroutines directly that are only available within the appropriate
     scope and only after that declaration:

         no warnings "experimental::lexical_subs";

         use feature 'lexical_subs';

         my sub lexical { ... }

         our sub shared { ... }

         state sub static { ... }

     For more check out 

==   Neat fixes   ==

=    qw(...) can no longer be used as parentheses    =

     You can no longer write:

         foreach my $foo qw(a b c d e) {

     you must now enclose the ``qw()'' within quotes:

         foreach my $foo ( qw(a b c d e) ) {

=    require dies for unreadable files    =

     Previously if you attempted to ``require'' a file and there wasn't a
     readable file of that name in your specified location, ``require'' 
     ignore the file and search @INC. Now it does not.

==   Other things   ==

     There are a few module changes, deprecations and selected bug-fixes as
     well. Check the 
     perldelta document for more.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/melbourne-pm/attachments/20130604/9d30a38e/attachment.html>

More information about the Melbourne-pm mailing list