SlideShare ist ein Scribd-Unternehmen logo
1 von 128
Downloaden Sie, um offline zu lesen
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
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
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
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;
}
__END__
Andrew Shitov
mail@andy.sh | http://andy.sh
DORS/CLUC, Zagreb, 2008

Weitere ähnliche Inhalte

Mehr von Andrew Shitov

The Joy of Smartmatch
The Joy of SmartmatchThe Joy of Smartmatch
The Joy of Smartmatch
Andrew Shitov
 

Mehr von Andrew Shitov (20)

Perl6 one-liners
Perl6 one-linersPerl6 one-liners
Perl6 one-liners
 
Creating a compiler in Perl 6
Creating a compiler in Perl 6Creating a compiler in Perl 6
Creating a compiler in Perl 6
 
Fun with Raspberry PI (and Perl)
Fun with Raspberry PI (and Perl)Fun with Raspberry PI (and Perl)
Fun with Raspberry PI (and Perl)
 
Perl6 in-production
Perl6 in-productionPerl6 in-production
Perl6 in-production
 
Параллельные вычисления в Perl 6
Параллельные вычисления в Perl 6Параллельные вычисления в Perl 6
Параллельные вычисления в Perl 6
 
AllPerlBooks.com
AllPerlBooks.comAllPerlBooks.com
AllPerlBooks.com
 
Perl 6 for Concurrency and Parallel Computing
Perl 6 for Concurrency and Parallel ComputingPerl 6 for Concurrency and Parallel Computing
Perl 6 for Concurrency and Parallel Computing
 
The Joy of Smartmatch
The Joy of SmartmatchThe Joy of Smartmatch
The Joy of Smartmatch
 
YAPC::Europe 2013
YAPC::Europe 2013YAPC::Europe 2013
YAPC::Europe 2013
 
Perl 7, the story of
Perl 7, the story ofPerl 7, the story of
Perl 7, the story of
 
Язык программирования Go для Perl-программистов
Язык программирования Go для Perl-программистовЯзык программирования Go для Perl-программистов
Язык программирования Go для Perl-программистов
 
What's new in Perl 5.14
What's new in Perl 5.14What's new in Perl 5.14
What's new in Perl 5.14
 
Что нового в Perl 5.14
Что нового в Perl 5.14Что нового в Perl 5.14
Что нового в Perl 5.14
 
Perl6 grammars
Perl6 grammarsPerl6 grammars
Perl6 grammars
 
Text in search queries with examples in Perl 6
Text in search queries with examples in Perl 6Text in search queries with examples in Perl 6
Text in search queries with examples in Perl 6
 
There's more than one way to empty it
There's more than one way to empty itThere's more than one way to empty it
There's more than one way to empty it
 
Perl 6 by example
Perl 6 by examplePerl 6 by example
Perl 6 by example
 
How to clean an array
How to clean an arrayHow to clean an array
How to clean an array
 
Perl 5.10 и 5.12
Perl 5.10 и 5.12Perl 5.10 и 5.12
Perl 5.10 и 5.12
 
Say Perl на весь мир
Say Perl на весь мирSay Perl на весь мир
Say Perl на весь мир
 

Kürzlich hochgeladen

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Kürzlich hochgeladen (20)

Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 

Life With Perl