<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
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.<br>
<br>
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.<br>
<br>
All the best,<br>
<br>
Jacinta<br>
<br>
<div class="moz-forward-container">
<meta http-equiv="content-type" content="text/html;
charset=ISO-8859-1">
<br>
==== What's new in 5.18.0? ====<br>
<br>
Perl 5's yearly release rhythm is well established. Because
major<br>
releases come out every single year, a major release no longer<br>
introduces a slew of new features. Instead, it consists of a
smaller set<br>
of features and bug fixes. Upgrading to a new major version is
easier<br>
than it's ever been.<br>
<br>
On 18th May 2013, Perl 5.18.0 was released.<br>
<br>
What has changed?<br>
<br>
<br>
== More information ==<br>
<br>
In addition to this tip you may find it useful to read <br>
(<a moz-do-not-send="true"
href="http://search.cpan.org/dist/perl-5.18.0/pod/perldelta.pod">http://search.cpan.org/dist/perl-5.18.0/pod/perldelta.pod</a>)
the<br>
perldelta document as well as our earlier tip on<br>
(<a moz-do-not-send="true"
href="http://perltraining.com.au/tips/2012-08-08.html">http://perltraining.com.au/tips/2012-08-08.html</a>)
What's New in<br>
5.12, 5.14 and 5.16<br>
<br>
<br>
== Smart-match, given/when, lexical $_ all moved to
experimental ==<br>
<br>
There's now a new warnings category called "experimental". If
you use an<br>
experimental feature without disabling that warning, you'll be
told it's<br>
experimental. This allows developers to introduce new ideas
and see<br>
whether they end up with unexpected consequences. Things that
work will<br>
be removed from being experimental in a later release.<br>
<br>
On the other hand, some ideas that have ended up with much
confusion<br>
have been marked as experimental until this confusion is
clarified.<br>
<br>
Due to various special-casing, smart-match (and given/when as
a result) and<br>
separately, lexical $_ have been marked as experimental. Turn
off these <br>
warnings with the following:<br>
<br>
<pre> no warnings "experimental::smartmatch";</pre>
<pre> no warnings "experimental::lexical_topic";</pre>
<br>
or<br>
<br>
<pre> no warnings qw(experimental::smartmatch experimental::lexical_topic);</pre>
<br>
The special warnings IDs for each experimental feature, are
included<br>
with their warnings in (<a moz-do-not-send="true"
href="http://search.cpan.org/dist/perl-5.18.0/pod/perldiag.pod">http://search.cpan.org/dist/perl-5.18.0/pod/perldiag.pod</a>)
perldiag.<br>
<br>
<br>
== Hash overhaul ==<br>
<br>
In brief, hash ordering is now actually random for all hashes
(as we've<br>
been told for a long while, but which hasn't always been
strictly the<br>
case). Thus:<br>
<br>
<pre> my %hash1 = ( a => 1, b => 2, c => 3);</pre>
<pre> my %hash2 = %hash1;</pre>
<pre> say join " ", keys %hash1;</pre>
<pre> say join " ", keys %hash2;</pre>
<br>
would have previously printed out identical key ordering for
both hashes<br>
during each program run. This will no longer occur.<br>
<br>
<br>
== Unicode ==<br>
<br>
Perl now supports Unicode 6.2.<br>
<br>
You can also define your own names for characters for use in
``\N{}'',<br>
although if you begin a name with a digit or include commas in
the name<br>
etc, then that's a syntax error.<br>
<br>
<br>
= Set operations =<br>
<br>
You can do set operations (such as intersection) within
regular<br>
expressions character classes, for example:<br>
<br>
<pre> no warnings "experimental::regex_sets";</pre>
<pre> /(?[ \p{Thai} & \p{Digit} ])/</pre>
<br>
will match all the characters that are in the Thai script and
are also<br>
digits. It's experimental, so you may want to turn the warning
off.<br>
<br>
Sets can be combined further:<br>
<br>
<pre> /(?[ ( \p{Thai} + \p{Lao} ) & \p{Digit} ])</pre>
<br>
The union of Thai and Lao scripts intersected with digits
gives us all<br>
digits in Thai and Lao scripts.<br>
<br>
See more at (<a moz-do-not-send="true"
href="http://search.cpan.org/%7Erjbs/perl-5.18.0/pod/perlrecharclass.pod#Extended_Bracketed_Character_Classes">http://search.cpan.org/~rjbs/perl-5.18.0/pod/perlrecharclass.pod#<br>
Extended_Bracketed_Character_Classes</a>) perlrecharclass.<br>
<br>
<br>
== $^{LAST_FH} ==<br>
<br>
Should you ever want access to most recently read filename,
you can now<br>
use $^{LAST_FH}<br>
<br>
<pre> # read a line from a random (hopefully opened) file handle</pre>
<pre> my $string = < $file_handles[ rand @file_hands ] >; </pre>
<pre> # oops, too short, let's add another line from that file, too</pre>
<pre> if( length $string < MAX_LEN ) {</pre>
<pre> $string .= < $^{LAST_FH} >;</pre>
<pre> }</pre>
<br>
<br>
== Lexical subroutine ==<br>
<br>
It's been possible to create lexical subroutines of a type
using<br>
subroutine references:<br>
<br>
<pre> my $sub = sub {</pre>
<pre> ...</pre>
<pre> };</pre>
<pre> $sub->();</pre>
<br>
Now it's possible (experimentally) to create lexical, shared
and static<br>
subroutines directly that are only available within the
appropriate<br>
scope and only after that declaration:<br>
<br>
<pre> no warnings "experimental::lexical_subs";</pre>
<pre> use feature 'lexical_subs';</pre>
<pre> my sub lexical { ... }</pre>
<pre> our sub shared { ... }</pre>
<pre> state sub static { ... }</pre>
<br>
For more check out (<a moz-do-not-send="true"
href="http://search.cpan.org/%7Erjbs/perl-5.18.0/pod/perlsub.pod#Lexical_Subroutines">http://search.cpan.org/~rjbs/perl-5.18.0/pod/perlsub.pod#<br>
Lexical_Subroutines</a>) perlsub.<br>
<br>
<br>
== Neat fixes ==<br>
<br>
<br>
= qw(...) can no longer be used as parentheses =<br>
<br>
You can no longer write:<br>
<br>
foreach my $foo qw(a b c d e) {<br>
...<br>
}<br>
<br>
you must now enclose the ``qw()'' within quotes:<br>
<br>
foreach my $foo ( qw(a b c d e) ) {<br>
...<br>
}<br>
<br>
<br>
= require dies for unreadable files =<br>
<br>
Previously if you attempted to ``require'' a file and there
wasn't a<br>
readable file of that name in your specified location,
``require'' would<br>
ignore the file and search @INC. Now it does not.<br>
<br>
<br>
== Other things ==<br>
<br>
There are a few module changes, deprecations and selected
bug-fixes as<br>
well. Check the <a moz-do-not-send="true"
href="http://search.cpan.org/dist/perl-5.18.0/pod/perldelta.pod">(http://search.cpan.org/dist/perl-5.18.0/pod/perldelta.pod</a>)<br>
perldelta document for more.<br>
</div>
</body>
</html>