SlideShare a Scribd company logo
Life with Perl
Life with Perl
both 5 and 6
Life with Perl
both 5 and 6
5 stands for both 5.8.8 and 5.10
Versions of Perl (perlhist)
Lyrical digression
Life With Perl
Time measuring
5.000 17 October 1994
5.6.0 22 March 2000
5.8.0 18 July 2002
5.8.8 31 January 2006
5.10 18 December 2008
Versions of Perl (perlhist)
5.000 17 October 1994
5.6.0 22 March 2000
5.8.0 18 July 2002
5.8.8 31 January 2006
5.10 18 December 2008
6.0 ?
Versions of Perl (perlhist)
5.000 17 October 1994
5.6.0 22 March 2000
5.8.0 18 July 2002
5.8.8 31 January 2006
5.10 18 December 2008
6.0 Сhristmas
Versions of Perl (perlhist)
5.000 17 October 1994
5.6.0 22 March 2000
5.8.0 18 July 2002
5.8.8 31 January 2006
5.10 18 December 2008
6.0 2000
Versions of Perl (perlhist)
Perl 6 docs, specs, thoughts
RFCs
Apocalypses
Exegeses
Synopses
5 != 6
Lyrical digression
Perl 5 mess
Perl 6 clean-up
5 != 6
4 != 5
Programme (script?)
Compiler
Virtual machine (VM)
Byte-code
Programme (script?)
Compiler
Virtual machine (VM)
Byte-code
Basic
Forth
Jako
Lisp
m4
Ook
Perl 6
Perl 5
Python
Ruby
Scheme
Tcl
PASM
IMC
PBC
PIR
PIL
C#
J#
VB.NET
JScript.NET
managed C++
Ada (A#)
F#
COBOL.NET
FORTRAN.NET
Perl.NET
CLR
Java
JRE
Most practical compilers
languages/perl6 in parrot.tar.gz
Perl6::* on CPAN
PUGS
Rakudo
Most practical compilers
Rakudo
= =
parrot/langauges/perl6
Most practical compilers
Rakudo
= =
parrot/langauges/perl6 + years
PUGS. Made with Haskell
PUGS. Made with Haskell
Most full coverage of Perl 6 specs
PUGS. Made with Haskell
Most full coverage of Perl 6 specs
Needs latest version of GHC
Life With Perl
It is
not lyrics
PUGS. Made with Haskell
Most full coverage of Perl 6 specs
Needs latest version of GHC
Slow
PUGS. Made with Haskell
Most full coverage of Perl 6 specs
Needs latest version of GHC
Slow
Contains tests
Perl 6
perl.it
perl.it!
UTF-8
say and print
say
"俄罗斯新闻网";
say and print
say
"俄罗斯新闻网";
"俄罗斯新闻网".say;
say and print
say
"俄罗斯新闻网";
"俄罗斯新闻网".say;
"俄罗斯新闻网".say();
say and print
say
"string";
say
123;
say(12
+
45);
say and print
say
"string";
say
123;
say(12
+
45);
"string".say;
123.say;
say and print
say
"string";
say
123;
say(12
+
45);
"string".say;
123.say;
3.14.say;
String length
my
$str
=
"俄罗斯新闻网";
say
$str.length;
String length
my
$str
=
"俄罗斯新闻网";
say
$str.length;
say
$str.chars;



6
say
$str.bytes;



18
String concatenation
my
$string_a
=
"abcde";
my
$string_b
=
"fghij";
print
$string_a
.
$string_b;5
print
$string_a
~
$string_b;6
Lyrical digression
Different wishes
Different wishes
Variables
my
$string
=
"abcde";
my
@array
=
(10,
20,
30);
my
%hash
=
("one"
=>
10,












"two"
=>
20);
Variables
my
$string
=
"abcde";
my
@array
=
(10,
20,
30);
my
%hash
=
("one"
=>
10,












"two"
=>
20);
print
$string;
print
$string;
5
6
Variables
my
$string
=
"abcde";
my
@array
=
(10,
20,
30);
my
%hash
=
("one"
=>
10,












"two"
=>
20);
5
6
print
$array[1];
print
@array[1];
Variables
my
$string
=
"abcde";
my
@array
=
(10,
20,
30);
my
%hash
=
("one"
=>
10,












"two"
=>
20);
5
6
print
$hash{"one"};
print
%hash{"one"};
Variables
my
$string
=
"abcde";
my
@array
=
(10,
20,
30);
my
%hash
=
("one"
=>
10,












"two"
=>
20);
5
6
print
$hash{"one"};
print
%hash{"one"};
print
%hash<one>;
print
%hash<one
two>;
Contexts
my
@array
=
(5..10);
Contexts
my
@array
=
(5..10);
say
~@array; 5 6 7 8 9 10
Contexts
my
@array
=
(5..10);
say
~@array; 5 6 7 8 9 10
say
+@array;






6
Contexts
my
@array
=
(5..10);
say
~@array; 5 6 7 8 9 10
say
int
@array;



6
Contexts
my
@array
=
(5..10);
say
~@array; 5 6 7 8 9 10
say
int
@array;



6
say
~
hash
@array;
5

6



















7

8



















9

10
Contexts
my
$value
=
100;
say
$value;






100
Contexts
my
$value
=
100;
say
$value;






100
say
?$value;





1
Subroutines
sub
callme
($first,
$second)
{



say
"$first,
$second";
}
callme(10,
20);
Subroutines
sub
callme
($first,
$second)
{



say
"$first,
$second";
}
callme(10,
20);
callme
10,
20;
Subroutines
sub
callme
($first,
$second)
{



say
"$first,
$second";
}
callme(10,
20);
callme
10,
20;
callme
(10,
20);
Subroutines
sub
callme
($first,
$second)
{



say
"$first,
$second";
}
callme(10,
20);
callme
10,
20;
callme
(10,
20);
callme(second
=>
20,







first
=>
10);
Subroutines
sub
callme
(@a,
@b)
{



say
@a
~
",
"
~
@b;
}
my
@odd
=
(1,
3);
my
@even
=
(2,
4);
callme
@odd,
@even;

1
3,
2
4
Subroutines
sub
callme
($arg
is
rw)
sub
inc
($value,
$step
=
1)
Anonymous subroutines
my
$print_line_break
=
{



print
"<br
/>";
}
$print_line_break();
Anonymous subroutines
my
$square
=
‐>
($value)
{



$value
**
2;
}
say
$square(20);






400
Anonymous subroutines
my
$square
=
‐>
($value)
{



$value
**
2;
}
say
$square(20);






400
say
$square
20;
Cycles
for
@list
{



say
$_;
}
Cycles
for
@list
‐>
$value
{



say
$value;
}
Cycles
for
@list
‐>
$value
{



say
$value;
}
for
@list,
sub
($value)
{



say
$value;
}
Hyperoperators
my
@odd
=
(1,
3,
5);
my
@even
=
(2,
4,
6);
my
@sum
=
@odd
»+«
@even;

say
~@sum;



3
7
11
Hyperoperators
my
@odd
=
(1,
3,
5);
my
@even
=
(2,
4,
6);
my
@sum
=
@odd
»+«
@even;
say
~@sum;


my
@next
=
@sum
»+«
1;
say
~@next;


Hyperoperators
my
@odd
=
(1,
3,
5);
my
@even
=
(2,
4,
6);
my
@sum
=
@odd
>>+<<
@even;
say
~@sum;


my
@next
=
@sum
>>+<<
1;
say
~@next;


Hyperoperator monument
Junctions
say
"yes"
if
20
==
10
|
20
|
30;

say
"yes"
if
20
==
any
(10,
20,
30);
Junctions
say
"yes"
if
20
==
10
|
20
|
30;

say
"yes"
if
20
==
any
(10,
20,
30);
say
"no"
if
21
==
none
(10,
20,
30);
multi functions
multi
sub
the_name
($scalar)
{...}
multi
sub
the_name
($s1,
$s2)
{...}
multi
sub
the_name
(@array)
{...}
multi functions
multi
sub
the_name
($scalar)
{...}
multi
sub
the_name
($s1,
$s2)
{...}
multi
sub
the_name
(@array)
{...}
the_name($some_value);
the_name($value1,
$value2);
the_name(@some_array);
Overriding operators
multi
infix:<+>
($a,
$b)
{



return
$a
‐
$b;
}
say
10
+
20;




‐10
Overriding operators
multi
postfix:<@>
($power)
{



return
2
**
$power;
}
say
8@;

















256
Overriding operators
sub
postfix:<power_of_two>
($power)
{



return
2
**
$power;
}
say
8
power_of_two;





256
switch and case
given
($x)
{



when
"a"
{say
...}



when
"b"
{say
...}



when
/<[a‐z]>/
{...}



default

{...}
}
Smart matching
~~
Smart matching
$a
~~
$b
==
$b
~~
$a
Smart matching
my
$b;
$b
~~
undef
!defined
$b
Smart matching
my
$c
=
'abc';
$c
~~
'abc'
$c
eq
'abc'
Smart matching
my
@a
=
(1..3);
my
@b
=
(1..3);
@a
~~
@b
1
==
1
&&
2
==
2
&&
3
==
3
Smart matching
my
@f
=
('a'..'f');
@f
~~
'd'
grep
{$_
eq
'd'}
@f
Smart matching
my
%h
=
(a
=>
'alpha',









b
=>
'beta');
%h
~~
'a'
exists
$h{'a'}
Smart matching
my
%h
=
(a
=>
'alpha',









b
=>
'beta');
my
%hh
=
(b
=>
1,
a
=>
2);
%h
~~
%hh
[sort
keys
%h]
~~
[sort
keys
%hh]
Smart matching
Works
in Perl 5.10!
People think of Perl 6
I think of today's Perl 6
Classes
class
Alphabet
{
}
my
$abc
=
new
Alphabet;
Classes
class
Alphabet
{



has
$.Name;



has
$Length;
}
my
$abc
=
new
Alphabet;
$abc.Name
=
"Latin";
$abc.Length
=
26;
Classes
class
Alphabet
{



...



method
info



{






say
"$.Name;
$Length";



}
}
$abc.info();
Classes
class
Alphabet
{



method
BUILD
{...}



method
DESTROY
{...}
}
Inheritance
class
Characters
is
Alphabet
{
}
my
$chars
=
new
Characters;
$chars.info();
Inheritance
class
Characters




is
Alphabet



is
Unique



is
NonLatin
{
}
Roles (interfaces?)
role
HaveName
{



has
$Name;



method
GetName



{return
$.Name;}
}
class
NamedAbc
does
HaveName
{}
June 2003
June 2004
June 2004 2005
2005
2007?
2008?
Cancelled
Life With Perl
Perl 6
in
Perl 5.10
use
feature
qw(




say




switch




state
);
sub
f
{



state
$c;



say
++$c;
}
f();
f();
f();
1
2
3
//
defined-or
my
$c
=
0;
my
$d
=
$c
//
3;
say
$d;










0
my
$e
=
0;
my
$f
=
$e
||
4;
say
$f;










4
Perl 6 today is
Rakudo
www.rakudo.org
The Way Of The Camel
Rakudа-do
Rakudo
cd
languages/perl6/

make
perl6
Binding
my
$hour
=
14;

my
$summertime
:=
$hour;
say
$hour;

$summertime++;

say
$hour;
.WHAT
class
Language
{





has
$!Name;




method
give_name
($newname)
{









$!Name
=
$newname;





}




method
say_name
{









say
"This
is
$!Name";





}

}
my
$lang
=
Language.new();

$lang.give_name('Perl
6');

$lang.say_name();
.WHAT
class
Language
{

}
my
$lang
=
Language.new();

say
$lang.WHAT;
say
Language.WHAT;
say
'before';

try
{




die
'Bye!';

}

say
'after';
try
regex
language
{Perl|XML};
say
"ok"





if
'Perl'
~~
/<language>/;

say
"not
ok"





unless
'PHP'
~~
/<language>/;
Regexes
More
class
Foo{};
my
Foo
$x;
$x
=
Foo.new();
More
async
{




my
@sum
=
@odd
>>+<<
@even;
}
More
atomic
{




$a
‐=
100;




$b
+=
100;
}
Life With Perl
__END__
Andrew Shitov
mail@andy.sh | http://andy.sh
DORS/CLUC, Zagreb, 2008

More Related Content

DOC
Filelist
PDF
UNIX SHELL IN DBA EVERYDAY
KEY
Elastic search meetup 20/9/2012
PDF
Keynote: O PHP, Where Art Thou?
PDF
The 9th Bit: Encodings in Ruby 1.9
PDF
Как очистить массив
PDF
Что такое Moscow.pm (remix)
Filelist
UNIX SHELL IN DBA EVERYDAY
Elastic search meetup 20/9/2012
Keynote: O PHP, Where Art Thou?
The 9th Bit: Encodings in Ruby 1.9
Как очистить массив
Что такое Moscow.pm (remix)

Similar to Life With Perl (20)

PDF
PDF
PDF
Modern Perl for the Unfrozen Paleolithic Perl Programmer
PDF
Modern Perl for the Unfrozen Paleolithic Perl Programmer
KEY
Perl 5.16 and Beyond - YAPC::Asia 2011
PPT
2016年のPerl (Long version)
ODP
Whatsnew in-perl
PDF
What's new in Perl 5.14
PDF
Perl6 for-beginners
PDF
Perl 5.16 new features
PPTX
Unit 1-introduction to perl
PDF
Perl Programming - 01 Basic Perl
PDF
Perl 101
PDF
Perl 5.10 for People Who Aren't Totally Insane
PPT
Perl Development (Sample Courseware)
PDF
Perl 5.10
PDF
Old Dogs & New Tricks: What's New With Perl5 This Century
PDF
Modern Perl for Non-Perl Programmers
PPT
PERL - complete_Training_Modules_Ref.ppt
Modern Perl for the Unfrozen Paleolithic Perl Programmer
Modern Perl for the Unfrozen Paleolithic Perl Programmer
Perl 5.16 and Beyond - YAPC::Asia 2011
2016年のPerl (Long version)
Whatsnew in-perl
What's new in Perl 5.14
Perl6 for-beginners
Perl 5.16 new features
Unit 1-introduction to perl
Perl Programming - 01 Basic Perl
Perl 101
Perl 5.10 for People Who Aren't Totally Insane
Perl Development (Sample Courseware)
Perl 5.10
Old Dogs & New Tricks: What's New With Perl5 This Century
Modern Perl for Non-Perl Programmers
PERL - complete_Training_Modules_Ref.ppt
Ad

More from Andrew Shitov (20)

PDF
Perl jobs market in 2024, how good is it?
PDF
Perl6 one-liners
PDF
Creating a compiler in Perl 6
PPTX
Fun with Raspberry PI (and Perl)
PDF
Perl6 in-production
PDF
Параллельные вычисления в Perl 6
PDF
AllPerlBooks.com
PDF
Perl 6 for Concurrency and Parallel Computing
PDF
The Joy of Smartmatch
PDF
YAPC::Europe 2013
PDF
Perl 7, the story of
PDF
Язык программирования Go для Perl-программистов
PDF
Что нового в Perl 5.14
PDF
Perl6 grammars
PDF
Text in search queries with examples in Perl 6
PDF
There's more than one way to empty it
PDF
Perl 6 by example
PDF
How to clean an array
PDF
Perl 5.10 и 5.12
PDF
Say Perl на весь мир
Perl jobs market in 2024, how good is it?
Perl6 one-liners
Creating a compiler in Perl 6
Fun with Raspberry PI (and Perl)
Perl6 in-production
Параллельные вычисления в Perl 6
AllPerlBooks.com
Perl 6 for Concurrency and Parallel Computing
The Joy of Smartmatch
YAPC::Europe 2013
Perl 7, the story of
Язык программирования Go для Perl-программистов
Что нового в Perl 5.14
Perl6 grammars
Text in search queries with examples in Perl 6
There's more than one way to empty it
Perl 6 by example
How to clean an array
Perl 5.10 и 5.12
Say Perl на весь мир
Ad

Recently uploaded (20)

PDF
A comparative study of natural language inference in Swahili using monolingua...
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
Hybrid model detection and classification of lung cancer
PPTX
observCloud-Native Containerability and monitoring.pptx
PPTX
Tartificialntelligence_presentation.pptx
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PPTX
Final SEM Unit 1 for mit wpu at pune .pptx
PDF
A novel scalable deep ensemble learning framework for big data classification...
PDF
project resource management chapter-09.pdf
PPT
Module 1.ppt Iot fundamentals and Architecture
PDF
Zenith AI: Advanced Artificial Intelligence
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
PPTX
Chapter 5: Probability Theory and Statistics
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Hindi spoken digit analysis for native and non-native speakers
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PDF
Architecture types and enterprise applications.pdf
PPTX
Programs and apps: productivity, graphics, security and other tools
A comparative study of natural language inference in Swahili using monolingua...
Group 1 Presentation -Planning and Decision Making .pptx
Hybrid model detection and classification of lung cancer
observCloud-Native Containerability and monitoring.pptx
Tartificialntelligence_presentation.pptx
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
Final SEM Unit 1 for mit wpu at pune .pptx
A novel scalable deep ensemble learning framework for big data classification...
project resource management chapter-09.pdf
Module 1.ppt Iot fundamentals and Architecture
Zenith AI: Advanced Artificial Intelligence
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
Chapter 5: Probability Theory and Statistics
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Hindi spoken digit analysis for native and non-native speakers
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
NewMind AI Weekly Chronicles - August'25-Week II
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
Architecture types and enterprise applications.pdf
Programs and apps: productivity, graphics, security and other tools

Life With Perl