What is new in Perl 5.10? <ul><li>Paul Fenwick </li></ul><ul><li>Audrey Tang </li></ul><ul><li>Leon Brocard </li></ul>
slidehist <ul><li>Monday: I'm presenting? </li></ul><ul><li>Tuesday: download Paul's slides </li></ul><ul><li>Wednesday: t...
perlhist <ul><li>1987: 1.0 </li></ul><ul><li>1988: 2.0 </li></ul><ul><li>1989: 3.0... </li></ul><ul><li>1991: 4.0... </li>...
perlhist 5.0 <ul><li>1994: 5.0 </li></ul><ul><li>1995: 5.1 </li></ul><ul><li>1996: 5.2, 5.3 </li></ul><ul><li>1997: 5.4 </...
5.8 perlhist <ul><li>2002: 5.8.0 </li></ul><ul><li>2003: 5.8.1, 5.8.2 </li></ul><ul><li>2o04: 5.8.3, 5.8.4, 5.8.5, 5.8.6 <...
2007 <ul><li>Stable: 5.8.9 </li></ul><ul><li>New: 5.10 </li></ul><ul><li>New new: 6.0.0 </li></ul>
New features <ul><li>Perl 5.10 has new features </li></ul><ul><li>Sorry Sebastian </li></ul>
New? <ul><li>new lexically-scoped feature pragma: </li></ul><ul><li>use feature qw(say switch); </li></ul><ul><li>use feat...
Optimise programmer time <ul><li>Most advanced programming language ever! </li></ul><ul><li>Perl: print “hello
” </li></ul...
Save typing <ul><li>My poor fingers! </li></ul><ul><li>Also none of this nasty quoting business </li></ul><ul><li>This mig...
Or <ul><li>$c = $a | | $b is handy </li></ul><ul><li>confused by empty string, undef or zero </li></ul>
Defined or <ul><li>$c = $a // $b is handier </li></ul><ul><li>same as $c = defined($a) ? $a : $b </li></ul>
dor and err <ul><li>There's also low-precedence // </li></ul><ul><li>use feature qw(dor err); </li></ul><ul><li>fileno($x)...
State variables <ul><li>The old way of having a persistent variable: </li></ul><ul><li>{   my $i = 0;   sub incrementor { ...
State variables <ul><li>use feature 'state'; sub incrementor {   state $i = 0;   return $i++; } </li></ul>
Local caches <ul><li>State variables can live deep inside subroutines... </li></ul><ul><li>for my $x (...) {   for my $y (...
Switch <ul><li>Perl 5.10 introduces a native switch statement. </li></ul><ul><li>Similar to Perl 6's switch, and Switch.pm...
Guessing Game <ul><li>use feature qw(switch say); my @guessed; my $num = int(rand 100)+1; while (my $guess = <STDIN>) {   ...
foreach / when <ul><li>use feature 'switch'; foreach (@cool_things) {   when (/pirate/)  { $pirate++ }   when (/ninja/)  {...
Smart-match <ul><li>use feature '~~'; if ($x ~~ @array)  { say &quot;$x exists&quot;  } if ($x ~~ /ninja/)  { say &quot;Ni...
Smart-match <ul><li>use feature '~~'; if (@array ~~ $x)  { say &quot;$x exists&quot;  } if (/ninja/ ~~ $x)  { say &quot;Ni...
UNIVERSAL::DOES <ul><li>Traditionally isa would be used to determine the capabilities of a class: </li></ul><ul><li>provid...
Helicopter <ul><li>package Helicopter; sub DOES {   my ($this, $interface) = @_;   return 1 if ($interface eq &quot;Airpla...
Constant (un-)folding <ul><li>Perl 'folds' constants at compile time </li></ul><ul><li>9+5 gets converted to 14 </li></ul>...
Hash::Util::FieldHash <ul><li>5.10 comes with support for Field Hashes, which: </li></ul><ul><ul><li>Can use references as...
Assertions <ul><li>Perl 5.10 implements real assertions </li></ul><ul><li>Normally compiled away </li></ul><ul><li>Can be ...
User-defined lexical pragmata <ul><li>We've used lexical pragmata for years: { use strict; ... } </li></ul><ul><li>In Perl...
More modules <ul><li>encoding::warnings </li></ul><ul><li>Math::BigInt::FastCalc </li></ul><ul><li>Time::Piece </li></ul><...
CPANPLUS <ul><li>Hi Jos! </li></ul><ul><li>It's about time, isn't it? </li></ul><ul><li>Means we have many other modules i...
Regex engine <ul><li>perlreguts </li></ul><ul><li>No longer recursive </li></ul><ul><li>Single char char-classes treated a...
Other goodies <ul><li>Misc Attribute Decoration </li></ul><ul><li>$AUTOLOAD can be tainted </li></ul><ul><li>Source filter...
More other goodies <ul><li>Faster stat() on Windows </li></ul><ul><li>Relocatable installs </li></ul><ul><li>Overloading f...
More details? <ul><li>http://search.cpan.org/dist/perl/pod/perl594delta.pod </li></ul>
Questions?
When will it be out? <ul><li>Stable: 5.8.9 “by April 1st” </li></ul><ul><li>New: 5.10 “after lunch, before Christmas” </li...
Any other questions?
License <ul><li>These slides are Copyright 2006 Paul Fenwick, Audrey Tang, Leon Brocard </li></ul><ul><li>The text may be ...
Upcoming SlideShare
Loading in...5
×

What's new in Perl 5.10?

33,417

Published on

Perl 5.10 will be the next new stable version of Perl. Find out what features it will have.

Published in: Business, Technology
1 Comment
20 Likes
Statistics
Notes
No Downloads
Views
Total Views
33,417
On Slideshare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
672
Comments
1
Likes
20
Embeds 0
No embeds

No notes for slide
  • What's new in Perl 5.10?

    1. 1. What is new in Perl 5.10? <ul><li>Paul Fenwick </li></ul><ul><li>Audrey Tang </li></ul><ul><li>Leon Brocard </li></ul>
    2. 2. slidehist <ul><li>Monday: I'm presenting? </li></ul><ul><li>Tuesday: download Paul's slides </li></ul><ul><li>Wednesday: tweak design </li></ul><ul><li>Thursday: play with fonts </li></ul><ul><li>Friday: argh slides on a plane </li></ul><ul><li>Saturday: release! </li></ul>
    3. 3. perlhist <ul><li>1987: 1.0 </li></ul><ul><li>1988: 2.0 </li></ul><ul><li>1989: 3.0... </li></ul><ul><li>1991: 4.0... </li></ul><ul><li>1994: 5.0 </li></ul>
    4. 4. perlhist 5.0 <ul><li>1994: 5.0 </li></ul><ul><li>1995: 5.1 </li></ul><ul><li>1996: 5.2, 5.3 </li></ul><ul><li>1997: 5.4 </li></ul><ul><li>1998: 5.5... </li></ul><ul><li>2000: 5.6... </li></ul><ul><li>2002: 5.8 </li></ul>
    5. 5. 5.8 perlhist <ul><li>2002: 5.8.0 </li></ul><ul><li>2003: 5.8.1, 5.8.2 </li></ul><ul><li>2o04: 5.8.3, 5.8.4, 5.8.5, 5.8.6 </li></ul><ul><li>2005: 5.8.7 </li></ul><ul><li>2006: 5.8.8 </li></ul>
    6. 6. 2007 <ul><li>Stable: 5.8.9 </li></ul><ul><li>New: 5.10 </li></ul><ul><li>New new: 6.0.0 </li></ul>
    7. 7. New features <ul><li>Perl 5.10 has new features </li></ul><ul><li>Sorry Sebastian </li></ul>
    8. 8. New? <ul><li>new lexically-scoped feature pragma: </li></ul><ul><li>use feature qw(say switch); </li></ul><ul><li>use feature qw(:5.10); </li></ul><ul><li>use 5.10; </li></ul>
    9. 9. Optimise programmer time <ul><li>Most advanced programming language ever! </li></ul><ul><li>Perl: print “hello ” </li></ul><ul><li>Perl 6: say “hello” </li></ul><ul><li>Perl 5.10: say “hello” </li></ul>
    10. 10. Save typing <ul><li>My poor fingers! </li></ul><ul><li>Also none of this nasty quoting business </li></ul><ul><li>This might seem like it's trivial... </li></ul>
    11. 11. Or <ul><li>$c = $a | | $b is handy </li></ul><ul><li>confused by empty string, undef or zero </li></ul>
    12. 12. Defined or <ul><li>$c = $a // $b is handier </li></ul><ul><li>same as $c = defined($a) ? $a : $b </li></ul>
    13. 13. dor and err <ul><li>There's also low-precedence // </li></ul><ul><li>use feature qw(dor err); </li></ul><ul><li>fileno($x) dor die 'That's not a filehandle'; </li></ul><ul><li>fileno($x) err die 'That's not a filehandle'; </li></ul>
    14. 14. State variables <ul><li>The old way of having a persistent variable: </li></ul><ul><li>{ my $i = 0; sub incrementor { return $i++; } } </li></ul>
    15. 15. State variables <ul><li>use feature 'state'; sub incrementor { state $i = 0; return $i++; } </li></ul>
    16. 16. Local caches <ul><li>State variables can live deep inside subroutines... </li></ul><ul><li>for my $x (...) { for my $y (...) { state %seen; next if $seen{$x}{$y}++; } } </li></ul>
    17. 17. Switch <ul><li>Perl 5.10 introduces a native switch statement. </li></ul><ul><li>Similar to Perl 6's switch, and Switch.pm (source filter) </li></ul><ul><li>Built into the Perl interpreter </li></ul>
    18. 18. Guessing Game <ul><li>use feature qw(switch say); my @guessed; my $num = int(rand 100)+1; while (my $guess = <STDIN>) { chomp $guess; given($guess) { when (/D/) { say &quot;Give me an integer&quot; } when (@guessed) { say &quot;You've tried that&quot; } when ($num) { say &quot;Just right!&quot;; last } when ($_ < $num) { say &quot;Too low&quot;; continue } when ($_ > $num) { say &quot;Too high&quot;; continue } push(@guessed,$_); } } </li></ul>
    19. 19. foreach / when <ul><li>use feature 'switch'; foreach (@cool_things) { when (/pirate/) { $pirate++ } when (/ninja/) { $ninja++ } when (/robot/) { $robot++ } say &quot;$_ doesn't look cool...&quot;; } </li></ul><ul><li>when automatically calls next at the end of its block </li></ul>
    20. 20. Smart-match <ul><li>use feature '~~'; if ($x ~~ @array) { say &quot;$x exists&quot; } if ($x ~~ /ninja/) { say &quot;Ninja in string&quot;} if (@x ~~ /ninja/) { say &quot;Ninja in array&quot; } if ($key ~~ %hash) { say &quot;$key exists&quot; } if ($subref ~~ $arg) { say 'sub($arg) true' } </li></ul>
    21. 21. Smart-match <ul><li>use feature '~~'; if (@array ~~ $x) { say &quot;$x exists&quot; } if (/ninja/ ~~ $x) { say &quot;Ninja in string&quot;} if (/ninja/ ~~ @x) { say &quot;Ninja in array&quot; } if (%hash ~~ $key) { say &quot;$key exists&quot; } if ($arg ~~ $subref) { say 'sub($arg) true' } </li></ul><ul><li>~~ can be overloaded </li></ul>
    22. 22. UNIVERSAL::DOES <ul><li>Traditionally isa would be used to determine the capabilities of a class: </li></ul><ul><li>provides a way to show compatibility, without inheritance </li></ul><ul><li>$obj‐>isa('Logger'); </li></ul><ul><li>$obj‐>DOES('Logger'); </li></ul>
    23. 23. Helicopter <ul><li>package Helicopter; sub DOES { my ($this, $interface) = @_; return 1 if ($interface eq &quot;Airplane&quot;); return $this->SUPER::does($interface); } </li></ul>
    24. 24. Constant (un-)folding <ul><li>Perl 'folds' constants at compile time </li></ul><ul><li>9+5 gets converted to 14 </li></ul><ul><li>In Perl 5.10, exceptional constants are unfolded </li></ul><ul><li>They'll still throw run-time exceptions if you try to execute them </li></ul>
    25. 25. Hash::Util::FieldHash <ul><li>5.10 comes with support for Field Hashes, which: </li></ul><ul><ul><li>Can use references as hash keys </li></ul></ul><ul><ul><li>Reference-keys migrate correctly across threads </li></ul></ul><ul><ul><li>Entries to stale references are automatically deleted </li></ul></ul><ul><li>(Inside-Out objects work nicely) </li></ul>
    26. 26. Assertions <ul><li>Perl 5.10 implements real assertions </li></ul><ul><li>Normally compiled away </li></ul><ul><li>Can be enabled on a per-module basis </li></ul><ul><li># This is normally compiled away sub assert_sanity :assertion {...} # Enable assertions for MyModule perl -A=MyModule prog.pl </li></ul>
    27. 27. User-defined lexical pragmata <ul><li>We've used lexical pragmata for years: { use strict; ... } </li></ul><ul><li>In Perl 5.10 you can write your own! </li></ul><ul><li>%^H allows &quot;hints&quot; to be attached to the optree </li></ul><ul><li>use feature is implemented this way </li></ul>
    28. 28. More modules <ul><li>encoding::warnings </li></ul><ul><li>Math::BigInt::FastCalc </li></ul><ul><li>Time::Piece </li></ul><ul><li>Win32API::File </li></ul><ul><li>CPANPLUS </li></ul>
    29. 29. CPANPLUS <ul><li>Hi Jos! </li></ul><ul><li>It's about time, isn't it? </li></ul><ul><li>Means we have many other modules in the core... </li></ul>
    30. 30. Regex engine <ul><li>perlreguts </li></ul><ul><li>No longer recursive </li></ul><ul><li>Single char char-classes treated as literals </li></ul><ul><li>Trie optimisation of literal string alternations /foam|foal|foad/ => /foa[mld]/ </li></ul><ul><li>Aho-Corasick start-point optimisation </li></ul><ul><li>Regex engine </li></ul><ul><li>Pluggable: use re::engine::PCRE; </li></ul><ul><li>Named capture buffers </li></ul><ul><li>/$(?<price>d+)/ ... $+{price} </li></ul><ul><li>More </li></ul>
    31. 31. Other goodies <ul><li>Misc Attribute Decoration </li></ul><ul><li>$AUTOLOAD can be tainted </li></ul><ul><li>Source filters in @INC </li></ul><ul><li>encodings::warnings is lexical </li></ul><ul><li>Better threads </li></ul><ul><li>Faster UTF-8 </li></ul>
    32. 32. More other goodies <ul><li>Faster stat() on Windows </li></ul><ul><li>Relocatable installs </li></ul><ul><li>Overloading for re-blessed objects </li></ul><ul><li>Better Windows support </li></ul><ul><li>Smaller memory footprint (slightly faster) </li></ul><ul><li>More documentation </li></ul>
    33. 33. More details? <ul><li>http://search.cpan.org/dist/perl/pod/perl594delta.pod </li></ul>
    34. 34. Questions?
    35. 35. When will it be out? <ul><li>Stable: 5.8.9 “by April 1st” </li></ul><ul><li>New: 5.10 “after lunch, before Christmas” </li></ul><ul><li>New new: 6.0.0 “after lunch, before Christmas” </li></ul>
    36. 36. Any other questions?
    37. 37. License <ul><li>These slides are Copyright 2006 Paul Fenwick, Audrey Tang, Leon Brocard </li></ul><ul><li>The text may be distributed under your choice of any of the following: </li></ul><ul><ul><li>The license terms of Perl itself </li></ul></ul><ul><ul><li>GNU Free Documentation License </li></ul></ul><ul><ul><li>Creative Commons Attribution ShareAlike </li></ul></ul>
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×