what's new in perl 5.14
DESCRIPTION
An overview of new features appeared in the version 5.14 of the Perl programming language.TRANSCRIPT
What's new
in Perl 5.14
perldoc perlhist
5.10.02007−Dec−18
5.10 appeared at its 20th birthday
— Take part in our survey!
¿Are you using Perl >= 5.10?
saywas introduced
¿Are you using
say?
Seriously
The New History Began with
Modern Perl
Modern Perl
ModernPerl
Modern Perl termis often understood
too widely
But it's just NOT these
That's from a book published in 2009
OK, go further:perldoc perlhist
we'll skip all odd (not even) versions (5.11, 5.13) —
they are odd dev
5.12.02010−Apr−12
¿Are you using Perl >= 5.12?
— What is YAPC?
5.14.0RC12011−Apr−20
RC — is arelease candidate
Then was
RC2
And then
RC3
Well, Perl 6's wayis much longer
Perl 5.14is ready already
What's newin Perl 5.14?
perldoc perldelta
perldelta = = 5.14 – 5.12
NoticeAs described in perlpolicy, the release of Perl 5.14.0 marks the official end of support for Perl 5.10. Users of Perl 5.10 or earlier should consider upgrading to a more recent release of Perl.
Frankly speaking, it's not that easy to
update Perl's versionon existing machine
Modules are the most difficult part
Do you know how to reinstall
everything easily?
New
Syntax
1
Security
2
Remember...
register_globals = off
In PHP since version 4.2.0
$_GET["sql"]
Perl is secureby itself
Incompatibilities
3
Deprecations
4
Performance
5
Modulesand pragmas
6
Documentation
7
Diagnostics
8
Utilities
9
Install process
10
Platforms
11
Internals
12
Bug fixes
13
Опечатки
14
We'll only take a look at syntax and
regular expressions changes
Welcome,
Unicode 6.0!
(Well, it's time toWelcome, Perl 6.0!)
Unicode affects both strings and regexes
A bell
(fairy tale)
ASCII-characterBELL (0x7)
In Unicode 6.0BELL — 0x1F514
Panic!
Perl is calmand wise
Perl is calmand wise
. . . probably
In Perl
BELL = 0x0007
In Perl
BELL = 0x0007\N{BELL} = 0x0007
In Perl
BELL = 0x0007\N{BELL} = 0x00070x0007 = ALERT
BELL = 0x0007\N{BELL} = 0x00070x0007 = ALERTALERT = "\a"
BELL = 0x0007\N{BELL} = 0x00070x0007 = ALERTALERT = "\a"
\N{BEL} = 0x0007
BELL = 0x0007\N{BELL} = 0x00070x0007 = ALERTALERT = "\a"
\N{BEL} = 0x00070x1F514 — no name
BELL = 0x0007\N{BELL} = 0x00070x0007 = ALERTALERT = "\a"
\N{BEL} = 0x00070x1F514 — no name
0x1F514 = \N{U+1F514}
ALERT = "\a"\N{BEL} = 0x00070x1F514 — no name
0x1F514 = \N{U+1F514}
Plans for Perl 5.16
\N{BELL} = 0x1F514
0x1F514 — без имени0x1F514 = \N{U+1F514}
Plans for Perl 5.16
\N{BELL} = 0x1F514
replace existing \N{BELL}with \N{ALERT},\N{BEL} or "\a"
use feature 'unicode_strings';
It brings the hope
That everything is in Unicode
How to turn 5.14 on
use v5.14;
use strict; adds itself
behind the scene
vector stringversion string
abbreviated — v-string
5.10.0v5.10.0v5.10
What's new inregular expressions
(?^ . . .)
Switch off all the modifiers locally
"ABC" =~ /abc/i;
True
False
"ABC" =~ /a(?^:b)c/i;
True
"ABC" =~ /a(?^i:b)c/i;
Ingenious reason
$ perl5.14.0 -‐MData::Dumper -‐E'my $x = qr/abc/; say Dumper($x)'
$VAR1 = qr/(?^u:abc)/;
No changes after adding new modifiers to Perl
$ perl5.10.0 -‐MData::Dumper -‐E'my $x = qr/abc/; say Dumper($x)'
$VAR1 = qr/(?-‐xism:abc)/;
Will be changed after adding new modifiers to Perl
New modifiers
/l==
use locale;
/u==
use feature 'unicode_strings';
/d~~
no locale;no feature
'unicode_strings';
/d~~
no locale;no feature
'unicode_strings';
bydefault
/a
How many charactersmatch with
/\d/
How many charactersmatch with
/\d/
±420
for (0x0 .. 0x10FFFF) { my $char = chr($_); say $char if $char =~ /^\d$/;}
/\d/ matches any symbol
marked DIGIT in Unicode
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,٠ ١, ٢, ٣, ٤, ٥, ٦, ٧, ٨, ٩, ੦,
੧, ੨, ੩, ੪, ੫, ੬, ੭, ੮, ੯, ૦, ૧,
૨, ૩, ૪, ૫, ૬, ૭, ૮, ૯, ௦, ௧, ௨,
௩, ௪, ௫, ௬, ௭, ௮, ௯, ...
\d became a topic of arguments
/d's behaviouris stable,
but contradictory
d
/aWelcome
for (0x0 .. 0x10FFFF) { my $char = chr($_); say $char if $char =~ /^\d$/a;}
Only 10 ASCIIcharacters match
$ perl a1.pl | wc -‐l10
/a createsASCII versions
of the modifiers\d, \s и \w
And affects both \b and \B
/r
Non-destructive substitution
A substitutionthat do not change
original string
use v5.14;
my $version = "Perl 5.10";say $version =~ s/5\.10/5.14/r;
Result: Perl 5.14
my $english = "colour";my $american = $english =~ s/our/or/r;
Arrays and hashes
Extra noise chars to be removed
That featureis experimental
use v5.14;
my $a = [];push $a, 3, 5, 7;
use v5.10;
my $a = [];push @$a, 3, 5, 7;
(Likewise @a[1] in Perl 6)
And more
push/pop @$arrayref
push/pop $arrayref
shift/unshift @$arrayref
shift/unshift $arrayref
splice @$arrayref
splice $arrayref
keys/values %$hashref
keys/values $hashref
keys/values @$arrayref
keys/values $arrayref
each %$href / @$aref
each $href / $aref
given returns the last
evaluated value
say mysub(7);
sub mysub { given($_[0]) { "few" when 3; "OK" when 5; "many" when 7; "?"; }}
(For thosewho omit
return keyword)
git blame
Aaron Crane, Abhijit Menon-Sen, Abigail, Ævar Arnfjörð Bjarmason, Alastair Douglas, Alexander Alekseev, Alexander Hartmaier, Alexandr Ciornii, Alex Davies, Alex Vandiver, Ali Polatel, Allen Smith, Andreas König, Andrew Rodland, Andy Armstrong, Andy Dougherty, Aristotle Pagaltzis, Arkturuz, Arvan, A. Sinan Unur, Ben Morrow, Bo Lindbergh, Boris Ratner, Brad Gilbert, Bram, brian d foy, Brian Phillips, Casey West, Charles Bailey, Chas. Owens, Chip Salzenberg, Chris 'BinGOs' Williams, chromatic, Craig A. Berry, Curtis Jewell, Dagfinn Ilmari Mannsåker, Dan Dascalescu, Dave Rolsky, David Caldwell, David Cantrell, David Golden, David Leadbeater, David Mitchell, David Wheeler, Eric Brine, Father Chrysostomos, Fingle Nark, Florian Ragwitz, Frank Wiegand, Franz Fasching, Gene Sullivan, George Greer, Gerard Goossen, Gisle Aas, Goro Fuji, Grant McLean, gregor herrmann, H.Merijn Brand, Hongwen Qiu, Hugo van der Sanden, Ian Goodacre, James E Keenan, James Mastros, Jan Dubois, Jay Hannah, Jerry D. Hedden, Jesse Vincent, Jim Cromie, Jirka Hruška, John Peacock, Joshua ben Jore, Joshua Pritikin, Karl Williamson, Kevin Ryde, kmx, Lars Dɪᴇᴄᴋᴏᴡ 迪拉斯, Larwan
Berke, Leon Brocard, Leon Timmermans, Lubomir Rintel, Lukas Mai, Maik Hentsche, Marty Pauley, Marvin Humphrey, Matt Johnson, Matt S Trout, Max Maischein, Michael Breen, Michael Fig, Michael G Schwern, Michael Parker, Michael Stevens, Michael Witten, Mike Kelly, Moritz Lenz, Nicholas Clark, Nick Cleaton, Nick Johnston, Nicolas Kaiser, Niko Tyni, Noirin Shirley, Nuno Carvalho, Paul Evans, Paul Green, Paul Johnson, Paul Marquess, Peter J. Holzer, Peter John Acklam, Peter Martini, Philippe Bruhat (BooK), Piotr Fusik, Rafael Garcia-Suarez, Rainer Tammer, Reini Urban, Renee Baecker, Ricardo Signes, Richard Möhn, Richard Soderberg, Rob Hoelz, Robin Barker, Ruslan Zakirov, Salvador Fandiño, Salvador Ortiz Garcia, Shlomi Fish, Sinan Unur, Sisyphus, Slaven Rezic, Steffen Müller, Steve Hay, Steven Schubiger, Steve Peters, Sullivan Beck, Tatsuhiko Miyagawa, Tim Bunce, Todd Rinaldo, Tom Christiansen, Tom Hukins, Tony Cook, Tye McQueen, Vadim Konovalov, Vernon Lyon, Vincent Pit, Walt Mankowski, Wolfram Humann, Yves Orton, Zefram и Zsbán Ambrus.
use v5.14 or die;
Or at least
use v5.14 or v5.12 ;-)
__END__
Andrew Shitov [email protected]