• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
What's new in Perl 5.10?
 

What's new in Perl 5.10?

on

  • 41,782 views

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

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

Statistics

Views

Total Views
41,782
Views on SlideShare
41,627
Embed Views
155

Actions

Likes
19
Downloads
667
Comments
1

21 Embeds 155

http://www.slideshare.net 90
http://www.linkedin.com 17
http://thomas-fahle.blogspot.com 8
http://thomas-fahle.blogspot.de 8
http://blog.phuha.net 7
http://test-iodo.blogspot.com 5
http://vioan.blogspot.de 3
http://vioan.blogspot.com 2
http://phuha.net 2
http://www.filescon.com 2
http://thomas-fahle.blogspot.in 1
http://64.233.179.104 1
http://myvirtualsynagogue.com 1
http://globalwarmingcontroversy.com 1
http://myvirtualholiday.com 1
http://nanomanufacturers.com 1
http://geneticassessment.com 1
http://www.filestube.com 1
http://guide.over-blog.com 1
http://pic1.piczo.com 1
http://test-iodo.blogspot.ru 1
More...

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

11 of 1 previous next

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

What's new in Perl 5.10? What's new in Perl 5.10? Presentation Transcript

  • What is new in Perl 5.10?
    • Paul Fenwick
    • Audrey Tang
    • Leon Brocard
  • slidehist
    • Monday: I'm presenting?
    • Tuesday: download Paul's slides
    • Wednesday: tweak design
    • Thursday: play with fonts
    • Friday: argh slides on a plane
    • Saturday: release!
  • perlhist
    • 1987: 1.0
    • 1988: 2.0
    • 1989: 3.0...
    • 1991: 4.0...
    • 1994: 5.0
  • perlhist 5.0
    • 1994: 5.0
    • 1995: 5.1
    • 1996: 5.2, 5.3
    • 1997: 5.4
    • 1998: 5.5...
    • 2000: 5.6...
    • 2002: 5.8
  • 5.8 perlhist
    • 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
  • 2007
    • Stable: 5.8.9
    • New: 5.10
    • New new: 6.0.0
  • New features
    • Perl 5.10 has new features
    • Sorry Sebastian
  • New?
    • new lexically-scoped feature pragma:
    • use feature qw(say switch);
    • use feature qw(:5.10);
    • use 5.10;
  • Optimise programmer time
    • Most advanced programming language ever!
    • Perl: print “hello ”
    • Perl 6: say “hello”
    • Perl 5.10: say “hello”
  • Save typing
    • My poor fingers!
    • Also none of this nasty quoting business
    • This might seem like it's trivial...
  • Or
    • $c = $a | | $b is handy
    • confused by empty string, undef or zero
  • Defined or
    • $c = $a // $b is handier
    • same as $c = defined($a) ? $a : $b
  • dor and err
    • 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';
  • State variables
    • The old way of having a persistent variable:
    • { my $i = 0; sub incrementor { return $i++; } }
  • State variables
    • use feature 'state'; sub incrementor { state $i = 0; return $i++; }
  • Local caches
    • State variables can live deep inside subroutines...
    • for my $x (...) { for my $y (...) { state %seen; next if $seen{$x}{$y}++; } }
  • Switch
    • Perl 5.10 introduces a native switch statement.
    • Similar to Perl 6's switch, and Switch.pm (source filter)
    • Built into the Perl interpreter
  • Guessing 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 &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,$_); } }
  • foreach / when
    • use feature 'switch'; foreach (@cool_things) { when (/pirate/) { $pirate++ } when (/ninja/) { $ninja++ } when (/robot/) { $robot++ } say &quot;$_ doesn't look cool...&quot;; }
    • when automatically calls next at the end of its block
  • Smart-match
    • 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' }
  • Smart-match
    • 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' }
    • ~~ can be overloaded
  • 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');
  • Helicopter
    • package Helicopter; sub DOES { my ($this, $interface) = @_; return 1 if ($interface eq &quot;Airplane&quot;); return $this->SUPER::does($interface); }
  • Constant (un-)folding
    • 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
  • Hash::Util::FieldHash
    • 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
    • (Inside-Out objects work nicely)
  • Assertions
    • 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
  • User-defined lexical pragmata
    • We've used lexical pragmata for years: { use strict; ... }
    • In Perl 5.10 you can write your own!
    • %^H allows &quot;hints&quot; to be attached to the optree
    • use feature is implemented this way
  • More modules
    • encoding::warnings
    • Math::BigInt::FastCalc
    • Time::Piece
    • Win32API::File
    • CPANPLUS
  • CPANPLUS
    • Hi Jos!
    • It's about time, isn't it?
    • Means we have many other modules in the core...
  • Regex engine
    • perlreguts
    • No longer recursive
    • Single char char-classes treated as literals
    • Trie optimisation of literal string alternations /foam|foal|foad/ => /foa[mld]/
    • Aho-Corasick start-point optimisation
    • Regex engine
    • Pluggable: use re::engine::PCRE;
    • Named capture buffers
    • /$(?<price>d+)/ ... $+{price}
    • More
  • Other goodies
    • Misc Attribute Decoration
    • $AUTOLOAD can be tainted
    • Source filters in @INC
    • encodings::warnings is lexical
    • Better threads
    • Faster UTF-8
  • More other goodies
    • Faster stat() on Windows
    • Relocatable installs
    • Overloading for re-blessed objects
    • Better Windows support
    • Smaller memory footprint (slightly faster)
    • More documentation
  • More details?
    • http://search.cpan.org/dist/perl/pod/perl594delta.pod
  • Questions?
  • When will it be out?
    • Stable: 5.8.9 “by April 1st”
    • New: 5.10 “after lunch, before Christmas”
    • New new: 6.0.0 “after lunch, before Christmas”
  • Any other questions?
  • License
    • 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 ShareAlike