Slideshare.net (beta)

 
Post to TwitterPost to Twitter
Post: 
Myspace Hi5 Friendster Xanga LiveJournal Facebook Blogger Tagged Typepad Freewebs BlackPlanet gigya icons

All comments

Add a comment on Slide 1

If you have a SlideShare account, login to comment; else you can comment as a guest


Showing 1-50 of 14 (more)

What's new in Perl 5.10?

From acme, 2 years ago

Perl 5.10 will be the next new stable version of Perl. Find out wh more

16773 views  |  3 comments  |  13 favorites  |  531 downloads  |  4 embeds (Stats)
 

Categories

Add Category
 
 

Groups / Events

 
Embed
options

More Info

This slideshow is Public
Total Views: 16773
on Slideshare: 16764
from embeds: 9

Slideshow transcript

Slide 1: What is ne w in Pe rl 5.10? Paul Fenwick ● Audrey Tang ● Leon Brocard ●

Slide 2: slide hist Monday: I'm presenting? ● Tuesday: download Paul's slides ● Wednesday: tweak design ● Thursday: play with fonts ● Friday: argh slides on a plane ● Saturday: release! ●

Slide 3: pe rlhist 1987: 1.0 ● 1988: 2.0 ● 1989: 3.0... ● 1991: 4.0... ● 1994: 5.0 ●

Slide 4: pe rlhist 5.0 1994: 5.0 ● 1995: 5.1 ● 1996: 5.2, 5.3 ● 1997: 5.4 ● 1998: 5.5... ● 2000: 5.6... ● ●

Slide 5: 5.8 pe rlhist 2002: 5.8.0 ● 2003: 5.8.1, 5.8.2 ● 2o04: 5.8.3, 5.8.4, 5.8.5, 5.8.6 ● 2005: 5.8.7 ● 2006: 5.8.8 ●

Slide 6: 2007 Stable: 5.8.9 ● New: 5.10 ● New new: 6.0.0 ●

Slide 7: Ne w fe ature s Perl 5.10 has new features ● Sorry Sebastian ●

Slide 8: Ne w ? new lexically-scoped feature pragma: ● use feature qw(say switch); ● use feature qw(:5.10); ● use 5.10; ●

Slide 9: Optimise pro gramme r time Most advanced programming ● language ever! Perl: print “hello ” ● Perl 6: say “hello” ● Perl 5.10: say “hello” ●

Slide 10: Save typing My poor fingers! ● Also none of this nasty quoting ● business This might seem like it's trivial... ●

Slide 11: Or $c = $a | | $b is handy ● confused by empty string, undef or ● zero

Slide 12: De fine d o r $c = $a // $b is handier ● same as $c = defined($a) ? $a : $b ●

Slide 13: do r and e rr There's also low-precedence // ● use feature qw(dor err); ● fileno($x) dor die 'That's not a ● filehandle'; fileno($x) err die 'That's not a ● filehandle';

Slide 14: State variable s The old way of having a persistent ● variable: { ● my $i = 0; sub incrementor { return $i++; } }

Slide 15: State variable s use feature 'state'; ● sub incrementor { state $i = 0; return $i++; }

Slide 16: Lo cal cache s State variables can live deep inside ● subroutines... for my $x (...) { ● for my $y (...) { state %seen; next if $seen{$x}{$y}++; } }

Slide 17: Sw itch Perl 5.10 introduces a native switch ● statement. Similar to Perl 6's switch, and ● Switch.pm (source filter) Built into the Perl interpreter ●

Slide 18: Gue ssing Game use feature qw(switch say); ● my @guessed; my $num = int(rand 100)+1; while (my $guess = <STDIN>) { chomp $guess; given($guess) { when (/D/) { say "Give me an integer" } when (@guessed) { say "You've tried that" } when ($num) { say "Just right!"; last } when ($_ < $num) { say "Too low"; continue } when ($_ > $num) { say "Too high"; continue } push(@guessed,$_); } }

Slide 19: fo re ach / w he n use feature 'switch'; ● foreach (@cool_things) { when (/pirate/) { $pirate++ } when (/ninja/) { $ninja++ } when (/robot/) { $robot++ } say "$_ doesn't look cool..."; } when automatically calls next at the ● end of its block

Slide 20: Smart-match use feature '~~'; ● if ($x ~~ @array) { say "$x exists" } if ($x ~~ /ninja/) { say "Ninja in string"} if (@x ~~ /ninja/) { say "Ninja in array" } if ($key ~~ %hash) { say "$key exists" } if ($subref ~~ $arg) { say 'sub($arg) true' }

Slide 21: Smart-match use feature '~~'; ● if (@array ~~ $x) { say "$x exists" } if (/ninja/ ~~ $x) { say "Ninja in string"} if (/ninja/ ~~ @x) { say "Ninja in array" } if (%hash ~~ $key) { say "$key exists" } if ($arg ~~ $subref) { say 'sub($arg) true' } ~~ can be overloaded ●

Slide 22: UNIVERSAL::DOES Traditionally isa would be used to ● determine the capabilities of a class: provides a way to show compatibility, ● without inheritance $obj‐>isa('Logger'); ● $obj‐>DOES('Logger'); ●

Slide 23: He lico pte r package Helicopter; ● sub DOES { my ($this, $interface) = @_; return 1 if ($interface eq "Airplane"); return $this->SUPER::does($interface); }

Slide 24: Co nstant (un-)fo lding Perl 'folds' constants at compile time ● 9+5 gets converted to 14 ● In Perl 5.10, exceptional constants are ● unfolded They'll still throw run-time exceptions if ● you try to execute them

Slide 25: Hash::Util::Fie ldHash 5.10 comes with support for Field ● Hashes, which: – Can use references as hash keys – Reference-keys migrate correctly across threads – Entries to stale references are automatically deleted

Slide 26: Asse rtio ns Perl 5.10 implements real assertions ● Normally compiled away ● Can be enabled on a per-module basis ● # This is normally compiled away ● sub assert_sanity :assertion {...} # Enable assertions for MyModule perl -A=MyModule prog.pl

Slide 27: Use r-de fine d le xical pragmata We've used lexical pragmata for years: ● { use strict; ... } In Perl 5.10 you can write your own! ● %^H allows "hints" to be attached to ● the optree use feature is implemented this way ●

Slide 28: Mo re mo dule s encoding::warnings ● Math::BigInt::FastCalc ● Time::Piece ● Win32API::File ● CPANPLUS ●

Slide 29: CPANPLUS Hi Jos! ● It's about time, isn't it? ● Means we have many other modules ● in the core...

Slide 30: Re ge x e ngine perlreguts ● No longer recursive ● Single char char-classes treated as ● literals Trie optimisation of literal string ● alternations /foam|foal|foad/ => /foa[mld]/

Slide 31: Othe r go o die s Misc Attribute Decoration ● $AUTOLOAD can be tainted ● Source filters in @INC ● encodings::warnings is lexical ● Better threads ● Faster UTF-8 ●

Slide 32: Mo re o the r go o die s Faster stat() on Windows ● Relocatable installs ● Overloading for re-blessed objects ● Better Windows support ● Smaller memory footprint (slightly ● faster) More documentation ●

Slide 33: Mo re de tails? http://search.cpan.org/dist/perl/pod/perl594delta.pod ●

Slide 34: Que stio ns?

Slide 35: Whe n w ill it be o ut? Stable: 5.8.9 “by April 1st” ● New: 5.10 “after lunch, before ● Christmas” New new: 6.0.0 “after lunch, before ● Christmas”

Slide 36: Any o the r que stio ns?

Slide 37: Lice nse These slides are Copyright 2006 Paul ● Fenwick, Audrey Tang, Leon Brocard The text may be distributed under your ● choice of any of the following: – The license terms of Perl itself – GNU Free Documentation License – Creative Commons Attribution