SlideShare a Scribd company logo
1 of 69
Download to read offline
Perl 5.10
OSDC.tw 2009 4/19


scw at csie dot org
Who
Who?


     Larry Wall
Rafa¨l Garcia-Suarez
    e
When
When?


Perl 5.8.0:   July 18, 2002
When?


Perl 5.8.0:   July 18, 2002
Perl 5.8.9:   Dec 14, 2008
When?


Perl 5.10.0:   Dec 18, 2007
When?


Perl 5.10.0:   Dec 18, 2007
Perl 6:        By Xmas
What
What?


Compatible (almost)
  major upgrade
What?


 New language features
Interpreter improvements
What?


Features and inspiration
     from Perl 6
Where
Where?

Debian 5.0 lenny
Ubuntu 8.10 intrepid
Fedora 9
Where?


FreeBSD ports (2009-03-28)
ActivePerl 5.10.0.1004
How
How?


apt-get install perl
yum update perl
How?

portsnap fetch update
cd lang/perl5.10
make install clean
How?

portsnap fetch update
cd lang/perl5.10
make install clean
read /usr/ports/UPDATING !!!
Not root?
Not root!

$ wget http://www.cpan.org/authors/id/
  R/RG/RGARCIA/perl-5.10.0.tar.gz
$ tar zxf perl-5.10.0.tar.gz; cd perl-5.10.0
$ ./Configure -Dprefix=/usr/local
                         ˜
  -Duserelocatableinc
$ make -j 8 all test install
Why
a//a
a||a
Why?

$a // ”Comment?”
Why?

$a // ”Comment?”
defined $a ?
  $a : ”Comment?”
defined-or


Apply defined-or patch against
     perl 5.8 works, too
defined-or

my $price = mysql select(...)
           // ”not found”;
say ”Price at $price”
say


say = print + -l
Not enabled by default
feature


use feature qw( )
say, switch, state
feature

use feature ”:5.10”
use 5.010
use v5.10
perl -E
feature


      switch
In correct English!!
switch
given($foo) {
  when (undef) { say ’$foo is undefined’ }
  when (”foo”) { say ’$foo is str ”foo”’ }
  when ([1,3,5,7,9]) {
    say ’$foo is an odd digit’; continue;
  }
  when ($ < 100) { say ’$foo under 100’ }
  when (&func) { say ’func($foo) true’ }
  default { die q(I don’t know what to do
when

my $count = 0;
for (@array) {
  when (”foo”) { ++$count }
}
say ”array contains $count copies of ’foo’”;
given, when & default


given(EXPR) = do{ $ = EXPR; ... }
when($foo) = when($ ˜˜$foo)
default = when(1 == 1)
smart match

”Smart matching in detail” in perlsyn
$a˜˜$b the same to $b˜˜$a
keys for hash
content for array
PerlRE
Engine



De-recursivised
Engine




Trie
Engine



Aho-Corasick
Named Capture
Named capture

/(?<ip> d+.d+.d+.d+)
.-.-.[(?<time>.*?)]
.”(?<method>GET|POST)
.(?<request>[ˆ ]+)
/x
Named capture

/(?<ip> d+.d+.d+.d+)
.-.-.[(?<time>.*?)]
.”(?<method>GET|POST)
.(?<request>[ˆ ]+)
/x
$+{’ip’, ’time’, ’method’, ’request’}
backreference

/(.)1/
/(.)g1/
/(.)g{1}/
/(.)g{-1}/
/(?<letter>.)g{letter}/
/(?<letter>.)k<letter>/
Regexp::Keep
Regexp::Keep


s/(.*)?.*/$1/g
Regexp::Keep


s/(.*)?.*/$1/g
s/.*K?.*//g
PerlRE not Regular
Recursive
/ˆ(                        # start of line, capture buffer 1
      <                    # match an opening angle brack
          (? :             # match one of:

                 [ˆ <>]+   #        one or more non angle br

          |                #     ... or ...
               (?1)        #     recurse to bracket 1 and try
          )∗               # 0 or more times.
      >                    # match a closing angle bracket
  )                        # end capture buffer one
$/x                        # end of line
Recursive
/ˆ(                       # start of line, capture buffer 1
      <                   # match an opening angle brack
          (? :            # match one of:
             (? >
                [ˆ <>]+   #        one or more non angle br
             )
          |               #     ... or ...
             (?1)         #     recurse to bracket 1 and try
          )∗              # 0 or more times.
      >                   # match a closing angle bracket
  )                       # end capture buffer one
$/x                       # end of line
Recursive
/ˆ(                        # start of line, capture buffer 1
      <                    # match an opening angle brack
          (? :             # match one of:

                 [ˆ <>] + + #       one or more non angle b

          |                #     ... or ...
               (?1)        #     recurse to bracket 1 and tr
          )∗               # 0 or more times.
      >                    # match a closing angle bracket
  )                        # end capture buffer one
$/x                        # end of line
Backtracking Control Verbs
(*FAIL)
(*ACCEPT)
On (*FAIL)...
On (*FAIL)...


   (*PRUNE)
estart this trial (:)
On (*FAIL)...


aaaaaaaaaaaaaa
/a*(*PRUNE)a/
On (*FAIL)...


  (*THEN)
 ext branch (::)
On (*FAIL)...


aaaaaaaaaaaaa
/a*(*THEN)a/
On (*FAIL)...


aaaaaaaaaaaaaaaa
/a*(*THEN)a|a+/
On (*FAIL)...


  (*COMMIT)
ail the match (:::)
On (*FAIL)...


aaaaaaaaaaaaaaaa
/a*(*COMMIT)a/
demo
parse string
man perlre
man perldelta
Thank you!

More Related Content

What's hot

JavaForum Nord 2021: Java to Go - Google Go für Java-Entwickler
JavaForum Nord 2021: Java to Go - Google Go für Java-EntwicklerJavaForum Nord 2021: Java to Go - Google Go für Java-Entwickler
JavaForum Nord 2021: Java to Go - Google Go für Java-EntwicklerJan Stamer
 
R で解く FizzBuzz 問題
R で解く FizzBuzz 問題R で解く FizzBuzz 問題
R で解く FizzBuzz 問題Kosei ABE
 
CS50 Lecture3
CS50 Lecture3CS50 Lecture3
CS50 Lecture3昀 李
 
Sine Wave Generator with controllable frequency displayed on a seven segment ...
Sine Wave Generator with controllable frequency displayed on a seven segment ...Sine Wave Generator with controllable frequency displayed on a seven segment ...
Sine Wave Generator with controllable frequency displayed on a seven segment ...Karthik Rathinavel
 
Clean Coders Hate What Happens To Your Code When You Use These Enterprise Pro...
Clean Coders Hate What Happens To Your Code When You Use These Enterprise Pro...Clean Coders Hate What Happens To Your Code When You Use These Enterprise Pro...
Clean Coders Hate What Happens To Your Code When You Use These Enterprise Pro...Kevlin Henney
 
betterCode() Go: Einstieg in Go, Standard-Library und Ökosystem
betterCode() Go: Einstieg in Go, Standard-Library und ÖkosystembetterCode() Go: Einstieg in Go, Standard-Library und Ökosystem
betterCode() Go: Einstieg in Go, Standard-Library und ÖkosystemJan Stamer
 
Elixir - Tolerância a Falhas para Adultos - Secot VIII Sorocaba
Elixir - Tolerância a Falhas para Adultos - Secot VIII SorocabaElixir - Tolerância a Falhas para Adultos - Secot VIII Sorocaba
Elixir - Tolerância a Falhas para Adultos - Secot VIII SorocabaFabio Akita
 
Unix And C
Unix And CUnix And C
Unix And CDr.Ravi
 
re3 - modern regex syntax with a focus on adoption
re3 - modern regex syntax with a focus on adoptionre3 - modern regex syntax with a focus on adoption
re3 - modern regex syntax with a focus on adoptionAur Saraf
 
Emuladores
EmuladoresEmuladores
EmuladoresBayoch
 
Rust: код может быть одновременно безопасным и быстрым, Степан Кольцов
Rust: код может быть одновременно безопасным и быстрым, Степан КольцовRust: код может быть одновременно безопасным и быстрым, Степан Кольцов
Rust: код может быть одновременно безопасным и быстрым, Степан КольцовYandex
 
Introduction to Vim, the text editor
Introduction to Vim, the text editorIntroduction to Vim, the text editor
Introduction to Vim, the text editorVysakh Sreenivasan
 
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...Zyxware Technologies
 
Airlover 20030324 1
Airlover 20030324 1Airlover 20030324 1
Airlover 20030324 1Dr.Ravi
 
Img 20160309 0002 2
Img 20160309 0002 2Img 20160309 0002 2
Img 20160309 0002 2jordonj98
 

What's hot (20)

JavaForum Nord 2021: Java to Go - Google Go für Java-Entwickler
JavaForum Nord 2021: Java to Go - Google Go für Java-EntwicklerJavaForum Nord 2021: Java to Go - Google Go für Java-Entwickler
JavaForum Nord 2021: Java to Go - Google Go für Java-Entwickler
 
Dicas de SSH
Dicas de SSHDicas de SSH
Dicas de SSH
 
R で解く FizzBuzz 問題
R で解く FizzBuzz 問題R で解く FizzBuzz 問題
R で解く FizzBuzz 問題
 
CS50 Lecture3
CS50 Lecture3CS50 Lecture3
CS50 Lecture3
 
Sine Wave Generator with controllable frequency displayed on a seven segment ...
Sine Wave Generator with controllable frequency displayed on a seven segment ...Sine Wave Generator with controllable frequency displayed on a seven segment ...
Sine Wave Generator with controllable frequency displayed on a seven segment ...
 
Clean Coders Hate What Happens To Your Code When You Use These Enterprise Pro...
Clean Coders Hate What Happens To Your Code When You Use These Enterprise Pro...Clean Coders Hate What Happens To Your Code When You Use These Enterprise Pro...
Clean Coders Hate What Happens To Your Code When You Use These Enterprise Pro...
 
betterCode() Go: Einstieg in Go, Standard-Library und Ökosystem
betterCode() Go: Einstieg in Go, Standard-Library und ÖkosystembetterCode() Go: Einstieg in Go, Standard-Library und Ökosystem
betterCode() Go: Einstieg in Go, Standard-Library und Ökosystem
 
Elixir - Tolerância a Falhas para Adultos - Secot VIII Sorocaba
Elixir - Tolerância a Falhas para Adultos - Secot VIII SorocabaElixir - Tolerância a Falhas para Adultos - Secot VIII Sorocaba
Elixir - Tolerância a Falhas para Adultos - Secot VIII Sorocaba
 
Get Kata
Get KataGet Kata
Get Kata
 
2.5 dfs & bfs
2.5 dfs & bfs2.5 dfs & bfs
2.5 dfs & bfs
 
Unix And C
Unix And CUnix And C
Unix And C
 
re3 - modern regex syntax with a focus on adoption
re3 - modern regex syntax with a focus on adoptionre3 - modern regex syntax with a focus on adoption
re3 - modern regex syntax with a focus on adoption
 
Emuladores
EmuladoresEmuladores
Emuladores
 
Rust: код может быть одновременно безопасным и быстрым, Степан Кольцов
Rust: код может быть одновременно безопасным и быстрым, Степан КольцовRust: код может быть одновременно безопасным и быстрым, Степан Кольцов
Rust: код может быть одновременно безопасным и быстрым, Степан Кольцов
 
Introduction to Vim, the text editor
Introduction to Vim, the text editorIntroduction to Vim, the text editor
Introduction to Vim, the text editor
 
Iteration
IterationIteration
Iteration
 
Fizzbuzzalooza
FizzbuzzaloozaFizzbuzzalooza
Fizzbuzzalooza
 
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...
Introduction to Bash Scripting, Zyxware Technologies, CSI Students Convention...
 
Airlover 20030324 1
Airlover 20030324 1Airlover 20030324 1
Airlover 20030324 1
 
Img 20160309 0002 2
Img 20160309 0002 2Img 20160309 0002 2
Img 20160309 0002 2
 

Similar to Perl 5.10 on OSDC.tw 2009

Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009Aslak Hellesøy
 
Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009Aslak Hellesøy
 
Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009Aslak Hellesøy
 
Advanced Regular Expressions Redux
Advanced Regular Expressions ReduxAdvanced Regular Expressions Redux
Advanced Regular Expressions ReduxJakub Nesetril
 
Ruby 程式語言簡介
Ruby 程式語言簡介Ruby 程式語言簡介
Ruby 程式語言簡介Wen-Tien Chang
 
Good Evils In Perl
Good Evils In PerlGood Evils In Perl
Good Evils In PerlKang-min Liu
 
Whatsnew in-perl
Whatsnew in-perlWhatsnew in-perl
Whatsnew in-perldaoswald
 
Maybe you do not know that ...
Maybe you do not know that ...Maybe you do not know that ...
Maybe you do not know that ...Viktor Turskyi
 
Linux shell script-1
Linux shell script-1Linux shell script-1
Linux shell script-1兎 伊藤
 
Ruby on rails presentation
Ruby on rails presentationRuby on rails presentation
Ruby on rails presentationSynbioz
 
Regular Expressions: Backtracking, and The Little Engine that Could(n't)?
Regular Expressions: Backtracking, and The Little Engine that Could(n't)?Regular Expressions: Backtracking, and The Little Engine that Could(n't)?
Regular Expressions: Backtracking, and The Little Engine that Could(n't)?daoswald
 
Ruby 入門 第一次就上手
Ruby 入門 第一次就上手Ruby 入門 第一次就上手
Ruby 入門 第一次就上手Wen-Tien Chang
 
Ruby 程式語言入門導覽
Ruby 程式語言入門導覽Ruby 程式語言入門導覽
Ruby 程式語言入門導覽Wen-Tien Chang
 
SWP - A Generic Language Parser
SWP - A Generic Language ParserSWP - A Generic Language Parser
SWP - A Generic Language Parserkamaelian
 
Licão 12 decision loops - statement iteration
Licão 12 decision loops - statement iterationLicão 12 decision loops - statement iteration
Licão 12 decision loops - statement iterationAcácio Oliveira
 
Ruby 程式語言綜覽簡介
Ruby 程式語言綜覽簡介Ruby 程式語言綜覽簡介
Ruby 程式語言綜覽簡介Wen-Tien Chang
 

Similar to Perl 5.10 on OSDC.tw 2009 (20)

Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009
 
Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009
 
Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009Ruby presentasjon på NTNU 22 april 2009
Ruby presentasjon på NTNU 22 april 2009
 
Advanced Regular Expressions Redux
Advanced Regular Expressions ReduxAdvanced Regular Expressions Redux
Advanced Regular Expressions Redux
 
Syntax
SyntaxSyntax
Syntax
 
Ruby 程式語言簡介
Ruby 程式語言簡介Ruby 程式語言簡介
Ruby 程式語言簡介
 
Cleancode
CleancodeCleancode
Cleancode
 
Good Evils In Perl
Good Evils In PerlGood Evils In Perl
Good Evils In Perl
 
Whatsnew in-perl
Whatsnew in-perlWhatsnew in-perl
Whatsnew in-perl
 
Maybe you do not know that ...
Maybe you do not know that ...Maybe you do not know that ...
Maybe you do not know that ...
 
Linux shell script-1
Linux shell script-1Linux shell script-1
Linux shell script-1
 
Ruby on rails presentation
Ruby on rails presentationRuby on rails presentation
Ruby on rails presentation
 
Regular Expressions: Backtracking, and The Little Engine that Could(n't)?
Regular Expressions: Backtracking, and The Little Engine that Could(n't)?Regular Expressions: Backtracking, and The Little Engine that Could(n't)?
Regular Expressions: Backtracking, and The Little Engine that Could(n't)?
 
Ruby 入門 第一次就上手
Ruby 入門 第一次就上手Ruby 入門 第一次就上手
Ruby 入門 第一次就上手
 
Ruby 程式語言入門導覽
Ruby 程式語言入門導覽Ruby 程式語言入門導覽
Ruby 程式語言入門導覽
 
Perl Moderno
Perl ModernoPerl Moderno
Perl Moderno
 
Scripting ppt
Scripting pptScripting ppt
Scripting ppt
 
SWP - A Generic Language Parser
SWP - A Generic Language ParserSWP - A Generic Language Parser
SWP - A Generic Language Parser
 
Licão 12 decision loops - statement iteration
Licão 12 decision loops - statement iterationLicão 12 decision loops - statement iteration
Licão 12 decision loops - statement iteration
 
Ruby 程式語言綜覽簡介
Ruby 程式語言綜覽簡介Ruby 程式語言綜覽簡介
Ruby 程式語言綜覽簡介
 

Perl 5.10 on OSDC.tw 2009