What's new in Perl 5.16 & 5.18

Sébastien Aperghis-Tramoni, sebastien@aperghis.net

Releases cycle

  • planned versions

    • one major release a year

    • a few minor releases every 2-3 months

  • short depreciation cycle

    • warning during at least one major cycle

    • effective removal at the next major release

    • modules removed from the core go on the CPAN

Perl 5.12

  • 5.12.0 on 2010.04.12

  • 5.12.1 on 2010.05.16

  • 5.12.2 on 2010.09.06

  • 5.12.3 on 2011.01.21

  • 5.12.4 on 2011.06.20

Perl 5.14

  • 5.14.0 on 2011.05.14

  • 5.14.1 on 2011.06.17

  • 5.14.2 on 2011.09.26

Perl 5.16

  • 5.16.0 on 2012.05.12

    • 5.12.x is no longer supported

  • 5.16.1 on 2012.08.08

  • 5.16.2 on 2012.11.01

Perl 5.18

  • 5.18.0 on 2012.05

What's new in Perl 5.16

New features

  • current_sub

    • __SUB__ keyword

    • reference to the current sub-routine

    • works in special blocks (5.16.1)

  • more keywords are now available in CORE::

New features

  • unicode_eval

    • eval() always evaluates the given string as Unicode

  • evalbytes

    • evalbytes() always evaluates the given string as bytes

Behavior changes

  • substr() can now return a lvalue

  •  my $string = "The quick brown fox jumps over the lazy dog";
     my $mask1  = \substr($string, 4, 5);
     my $mask2  = \substr($string, -8);
     print "$$mask1 | $$mask2\n";  # prints "quick | lazy dog"
  •  $string = "Le vif zéphyr souffle sur ces kumquats disgracieux";
     print "$$mask1 | $$mask2\n";  # prints "if zé | gracieux"
  • tied now returns the actual scalar that holds the object to which the variable is tied

  •  Scalar::Util::weaken(tied $tied_variable);

Unicode

  • Unicode 6.1.0

  • except U+1F514 (BELL), which conflicts with U+0007 (BELL, ALERT, BEL) ; will be renamed in 5.18

  • some names and properties have been renamed

  • Perl accepts both old and new names

Unicode

  • charnames autoloaded on the first \N{...}

  • \N{...} now supports loose match

  • full Unicode support for all symbol names (methods, typeglobs, packages...)

Unicode

  • full case folding

  • gives better results when comparing two strings case-insensitively

  • now available via the fc() function and the \F sequence

  •  lc($str1) eq lc($str2)  # incorrect
     uc($str1) eq uc($str2)  # incorrect
  •  $str1 =~ /\Q$str2/i     # correct, but uses a regexp
  •  fc($str1) eq fc($str2)  # correct

New module

  • arybase - implementation of $[

Other changes

  • the values of $$, $<, $>, $(, $) are no longer cached

  • $$ can now be assigned to

  • $^X is now converted to an absolute path on OS X, FreeBSD and Solaris 10 & 11

  • the \$ and \[$] prototypes now accept any scalar lvalue argument

  • the _ prototype is now allowed before @ or %

Optimisations

  • empty DESTROY methods are no longer called (5.12)

  • DESTROY methods beginning with a return are no longer called

  • assignment to substr() in void context is now twice its previous speed

  • faster use VERSION, no longer loads feature.pm

Optimisations

  • faster glob() (but not on VMS)

  • faster search on Unicode properties in regexps

  • chained short-circuit operators (&&, ||, //) are now faster due to reduced optree traversal

Removed modules

  • Devel::DProf, Shell

  • Perl4 libraries (assert.pl, bigint.pl, getcwd.pl, getopt.pl hostname.pl, open2.pl, tainted.pl, etc)

Futures depreciations

  • swapping of $< and $>

  • sfio support

What's new in Perl 5.18

  • (as compiled from the perldelta of 5.7.0 ~ 5.7.8)

New features

  • even more keywords in CORE::

  • kill now supports negative signal names: KILL -HUP -$$

  • next, last and redo now supports computed labels

  • given now aliases the global $_, like foreach

  • ${^LAST_FH} contains the filehandle that was last read

New features

  • lexical subroutines (experimental)

  •  use feature "lexical_subs";
    
     state sub myfunc { ... }
     my sub myfunc { ... }
     our sub myfunc { ... }
  • warnings on experimental features

  •  no warnings "experimental::lexical_subs";
     use feature "lexical_subs";

Syntax changes

  • qw(..) no longer fools the parser

    •  for my $pony qw< Twilight Fluttershy Pinkie_Pie > { ... }  # WRONG
    •  for my $pony (qw< Twilight Fluttershy Pinkie_Pie >) { ... }
  • stricter parsing of s///e

Regexp changes

  • $&, $` and $' are no longer slow

  • \s now matches a vertical tab (\v)

  • literal unescaped { is now deprecated

    • must be escaped or part of a construct

    • catches typos like /\w{,5}/

    • provisioned for future syntax extensions

  • /(?{})/ and /(??{})/ have been heavily reworked

Regexp changes

  • regular expression set operations (?[ ])

  • experimental: no warnings "experimental::regex_sets";

  • combines classes with & (intersection), + or | (union), - (substraction), ^ (symmetric difference)

  •  # match alphabetic characters, no digits
     /(?[ \w - \d ])/
  •  # match all the digits in the Thai or Laotian scripts
     /(?[ ( \p{Thai} + \p{Lao} ) & \p{Digit} ])/

Behavior changes

  • readline() with $/ = \N now reads N characters, not N bytes

Unicode

  • Unicode 6.2

  • \N{BELL} now refers to U+1F514 instead of U+0007

Other changes

  • study now is a complete no-op

  • require now dies for unreadable files

  • do now always sets $@ (like eval)

  • do function now uses as a file name what function returns

  • several fixes on the formats

Optimisations

  • new hash function: Murmurhash-32 v3

  • new copy-on-write mechanism

  • in regexps, matching against Unicode properties is faster

  • pack with constant arguments is now constant folded when possible

  • .. x .. is now constant folded at compile time when possible

Depreciations

  • syntax

    • lexical $_ (too confusing, too complex)

  • modules

    • CPANPLUS and its deps, Archive::Extract, Locale::Maketext::Simple, Log::Message, Log::Message::Simple, Module::Pluggable, Object::Accessor, Params::Check, Term::UI

    • Filter::Simple, PerlIO::mmap

    • Pod::LaTeX, Pod::Parser, SelfLoader

    • B::Lint, Text::Soundex, Thread.pm

Discontinued support

  • platforms

    • EPOC, MPE/iX, UTS Global, VM/ESA, Rhapsody

Future discontinued support

  • platforms

    • BeOS, djgpp, dgux

  • compilers

    • Borland

Questions?

Thanks