Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Perl 5.22 and You
Search
Ricardo Signes
June 18, 2015
Programming
0
83
Perl 5.22 and You
Ricardo Signes
June 18, 2015
Tweet
Share
More Decks by Ricardo Signes
See All by Ricardo Signes
Perl 5 at 20: Perl v5.20.0
rjbs
1
100
1.21 Gigawatts
rjbs
3
750
Perl 5: Postcards from the Edge
rjbs
1
1.1k
Perl: Today, Tomorrow, and Christmas
rjbs
0
150
Perl 5.16 for the Working Programmer
rjbs
0
120
Perl 5.14 for Pragmatists
rjbs
0
110
Perl 5.12 for Everyday Use
rjbs
0
220
Dist::Zilla — raaaaaaaaar!
rjbs
1
570
Validating Data Everywhere with Rx
rjbs
0
190
Other Decks in Programming
See All in Programming
2025年版 サーバーレス Web アプリケーションの作り方
hayatow
23
25k
iOSエンジニア向けの英語学習アプリを作る!
yukawashouhei
0
170
ててべんす独演会〜Flowの全てを語ります〜
tbsten
1
220
Playwrightはどのようにクロスブラウザをサポートしているのか
yotahada3
7
2.2k
CSC509 Lecture 03
javiergs
PRO
0
320
CSC305 Lecture 03
javiergs
PRO
0
230
高度なUI/UXこそHotwireで作ろう Kaigi on Rails 2025
naofumi
4
3k
パフォーマンスチューニングで Web 技術を深掘り直す
progfay
18
4.8k
Model Pollution
hschwentner
1
180
SpecKitでどこまでできる? コストはどれくらい?
leveragestech
0
420
AIを活用したレシート読み取り機能の開発から得られた実践知 / AI Receipt Scan Practice
rockname
2
1.5k
大規模アプリのDIフレームワーク刷新戦略 ~過去最大規模の並行開発を止めずにアプリ全体に導入するまで~
mot_techtalk
0
330
Featured
See All Featured
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
188
55k
We Have a Design System, Now What?
morganepeng
53
7.8k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
2.6k
Product Roadmaps are Hard
iamctodd
PRO
54
11k
Bash Introduction
62gerente
615
210k
Practical Orchestrator
shlominoach
190
11k
Large-scale JavaScript Application Architecture
addyosmani
514
110k
KATA
mclloyd
32
14k
Making Projects Easy
brettharned
118
6.4k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
26
3.1k
For a Future-Friendly Web
brad_frost
180
9.9k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
9
840
Transcript
Perl 5.22 your highly syntactic programming pal
5.x
5.x •every year a new stable perl 5
5.x •every year a new stable perl 5 •each one
better* than the last
5.x •every year a new stable perl 5 •each one
better* than the last •every month a new dev perl 5
5.x •every year a new stable perl 5 •each one
better* than the last •every month a new dev perl 5 •each one different than the last
5.x •every year a new stable perl 5 •each one
better* than the last •every month a new dev perl 5 •each one different than the last * says me
Code Ejection
Code Ejection delete the old crazy stuff
Code Ejection delete the old crazy stuff (to make room
for the new crazy stuff)
sigilless style
sigilless style push @array, 1, 2, 3, 4;
sigilless style push @array, 1, 2, 3, 4; for (keys
%hash) { ... }
sigilless style push @array, 1, 2, 3, 4; for (keys
%hash) { ... }
sigilless style push @array, 1, 2, 3, 4; for (keys
%hash) { ... } push array, 1, 2, 3, 4;
sigilless style push @array, 1, 2, 3, 4; for (keys
%hash) { ... } push array, 1, 2, 3, 4; for (keys hash) { ... }
sigilless style push @array, 1, 2, 3, 4; for (keys
%hash) { ... } push array, 1, 2, 3, 4; for (keys hash) { ... }
hash refauxrence
hash refauxrence my $value = $hash{key};
hash refauxrence my $value = $hash{key}; $hash{key} = $new;
hash refauxrence my $value = $hash{key}; $hash{key} = $new;
hash refauxrence my $value = $hash{key}; $hash{key} = $new; my
$value = %hash->{key};
hash refauxrence my $value = $hash{key}; $hash{key} = $new; my
$value = %hash->{key}; %hash->{key} = $new;
hash refauxrence my $value = $hash{key}; $hash{key} = $new; my
$value = %hash->{key}; %hash->{key} = $new;
?regex?
?regex? for (1..10) { say if /./ }
?regex? for (1..10) { say if /./ } for (1..10)
{ say if ?.? }
?regex? for (1..10) { say if /./ } for (1..10)
{ say if ?.? }
?regex? for (1..10) { say if /./ } for (1..10)
{ say if ?.? } for (1..10) { say if m?.? }
collection definedness
collection definedness if (defined @array) { ... }
collection definedness if (defined @array) { ... }
collection definedness if (defined @array) { ... } if (defined
%hash) { ... }
collection definedness if (defined @array) { ... } if (defined
%hash) { ... }
"\cX" "\c@" "\c " "\c牃" "\c¿"
"\cX" "\c@" "\c " "\c牃" "\c¿" "\cX" ==> CANCEL
"\cX" "\c@" "\c " "\c牃" "\c¿" "\cX" ==> CANCEL "\c@"
==> NUL
"\cX" "\c@" "\c " "\c牃" "\c¿" "\cX" ==> CANCEL "\c@"
==> NUL "\c " ==> GRAVE ACCENT
"\cX" "\c@" "\c " "\c牃" "\c¿" "\cX" ==> CANCEL "\c@"
==> NUL "\c " ==> GRAVE ACCENT "\c牃" ==> LATIN CAPITAL LETTER X
"\cX" "\c@" "\c " "\c牃" "\c¿" "\cX" ==> CANCEL "\c@"
==> NUL "\c " ==> GRAVE ACCENT "\c牃" ==> LATIN CAPITAL LETTER X "\c¿" ==> Hmmm…
~$ perl -de0 Loading DB routines from perl5db.pl version 1.28
Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. main::(-e:1): 0 DB<1>
~$ perl -de0 Loading DB routines from perl5db.pl version 1.28
Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. main::(-e:1): 0 DB<1> x "\c¿"
~$ perl -de0 Loading DB routines from perl5db.pl version 1.28
Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. main::(-e:1): 0 DB<1> x "\c¿" 0 '??'
None
DB<1> $str = q{"\c}
DB<1> $str = q{"\c} . chr(0xBF)
DB<1> $str = q{"\c} . chr(0xBF) That's ¿
DB<1> $str = q{"\c} . chr(0xBF) . q{"}; That's ¿
DB<1> $str = q{"\c} . chr(0xBF) . q{"}; DB<2> $res
= eval $str; That's ¿
DB<1> $str = q{"\c} . chr(0xBF) . q{"}; DB<2> $res
= eval $str; DB<3> x $res That's ¿
DB<1> $str = q{"\c} . chr(0xBF) . q{"}; DB<2> $res
= eval $str; DB<3> x $res 0 '?' That's ¿
DB<1> $str = q{"\c} . chr(0xBF) . q{"}; DB<2> $res
= eval $str; DB<3> x $res 0 '?' That's ¿
DB<1> $str = q{"\c} . chr(0xBF) . q{"}; DB<2> $res
= eval $str; DB<3> x $res 0 '?' DB<4> x ord $res That's ¿
DB<1> $str = q{"\c} . chr(0xBF) . q{"}; DB<2> $res
= eval $str; DB<3> x $res 0 '?' DB<4> x ord $res 0 255 That's ¿
None
say "\c¿";
say "\c¿";
say "\c¿"; FATAL!! Must be printable ASCII!
say $^H; # <-- private compile-time hints
say $^H; # <-- private compile-time hints say ; #
<-- private compile-time hints
say $^H; # <-- private compile-time hints say ; #
<-- private compile-time hints say $爳; # <-- private compile-time hints
$^K ==
$VT $^K ==
UNIVERSAL exports use UNIVERSAL;
UNIVERSAL exports use UNIVERSAL 'isa';
good bye, old modules
Module::Build
CGI.pm
you will be missed
you will be missed remembered
you will be missed remembered available on CPAN
good bye, jerkiness
p5p standards of conduct
p5p conduct •be civil •if you can't be civil, you
will be escorted out of the building
okay, but what's new in Perl??
filehandles
(<>) while (<>) { print if /awesome/; }
(<>) while (<>) { print if /awesome/; } $ some-thing
| your-program
(<>) while (<>) { print if /awesome/; } $ some-thing
| your-program $ your-program xyz.txt abc.txt
(<>) while (<>) { print if /awesome/; } while ($ARGV
= shift) { open(ARGV, $ARGV); while (<ARGV>) { ... } }
(<>) while (<>) { print if /awesome/; } while ($ARGV
= shift) { open(ARGV, $ARGV); while (<ARGV>) { ... } }
(<>) while (<>) { print if /awesome/; } $ some-thing
| your-program $ your-program xyz.txt abc.txt
(<>) while (<>) { print if /awesome/; } $ your-program
xyz.txt 'rm -rfv *|' $ some-thing | your-program $ your-program xyz.txt abc.txt
(<<>>) while (<<>>) { print if /awesome/; } $ your-program
xyz.txt abc.txt $ some-thing | your-program $ your-program xyz.txt 'rm -rfv *|'
open -| open my $fh, "-|", "program", @args;
implicit close open my $fh, '>', 'output.txt'; print { $fh
} $_ for @results;
implicit close { open my $fh, '>', 'output.txt'; print {
$fh } $_ for @results; }
{ open my $fh, '>', 'output.txt'; print { $fh }
$_ for @results; } # $fh is closed implicitly implicit close
{ open my $fh, '>', 'output.txt'; print { $fh }
$_ for @results; } # $fh is closed implicitly # but the disk is full implicit close
{ open my $fh, '>', 'output.txt'; print { $fh }
$_ for @results; } # $fh is closed implicitly # but the disk is full # so the close fails implicit close
{ open my $fh, '>', 'output.txt'; print { $fh }
$_ for @results; } # $fh is closed implicitly # but the disk is full # so the close fails # silently implicit close
{ open my $fh, '>', 'output.txt'; print { $fh }
$_ for @results; } # $fh is closed implicitly # but the disk is full # so the close fails # silently # :-( implicit close
{ open my $fh, '>', 'output.txt'; print { $fh }
$_ for @results; } # warning if close fails! implicit close
{ open my $fh, '>', 'output.txt'; print { $fh }
$_ for @results; } # warning if close fails! # (...and you can fatalize it) implicit close
{ use warnings FATAL => 'io'; open my $fh, '>',
'output.txt'; print { $fh } $_ for @results; } # warning if close fails! # (...and you can fatalize it) implicit close
Regex Stuff
establishing boundaries
establishing boundaries \b
establishing boundaries Don't think twice. It's all right. \b
establishing boundaries Don't think twice. It's all right. \b
establishing boundaries Don't think twice. It's all right. \b{w}
establishing boundaries Don't think twice. It's all right. \b{w}
establishing boundaries Don't think twice. It's all right. \b{w}
establishing boundaries Don't think twice. It's all right. \b{sb}
establishing boundaries Don't think twice. It's all right. \b{sb}
establishing boundaries Don't think twice. It's all right. /(?!>^)\b{sb}/
establishing boundaries Don't think twice. It's all right. \b{gcb}
establishing boundaries Don't think twice. It's all right. \b{gcb}
establishing boundaries Don't think twice. It's all right. split /\b{gcb}/
establishing boundaries Don't think twice. It's all right. split //
establishing boundaries Queensrÿche split //
establishing boundaries Queensrÿche split //
establishing boundaries Queensry¨che split //
establishing boundaries Queensrÿche split /\b{gcb}/
Avoid Capture
Avoid Capture qr/v(?:[0-9]+)(?:(?:\.[0-9]+)+(?:_[0-9]+)?)?/;
Avoid Capture
Avoid Capture qr/v (?:[0-9]+)
Avoid Capture qr/v (?:[0-9]+) (?: (?: \.[0-9]+ )+
Avoid Capture qr/v (?:[0-9]+) (?: (?: \.[0-9]+ )+ (?: _
[0-9]+ )? )?/x;
Avoid Capture qr/v ( [0-9]+) ( ( \.[0-9]+ )+ (
_ [0-9]+ )? )?/xn;
Avoid Capture qr/v [0-9]+ ( ( \.[0-9]+ )+ ( _
[0-9]+ )? )?/xn;
Avoid Capture qr/v ( [0-9]+) ( ( \.[0-9]+ )+ (
_ [0-9]+ )? )?/xn;
Avoid Capture qr/v (?-n: [0-9]+ ) ( ( \.[0-9]+ )+
(?-n: _ [0-9]+ )? )?/xn;
Avoid Capture qr/v (?<major> [0-9]+ ) ( ( \.[0-9]+ )+
(?<dev> _ [0-9]+ )? )?/xn; %vers = (major => $+{major}, dev => $+{dev});
Avoid Capture qr/v (?<major> [0-9]+ ) ( ( \.[0-9]+ )+
(?<dev> _ [0-9]+ )? )?/xn; %vers = %+{ qw(major dev) };
Pair Slices (from v5.20.0)
my @array = qw[ foo bar baz quux ]; my
@slice = @array[ 1, 3 ]; # Now @slice is ("bar", "quux")
my %hash = (a => 1, b => 2, c
=> 3); my @slice = @hash{ 'a', 'c' }; # Now @slice is (1, 3)
my %hash = (a => 1, b => 2, c
=> 3); my %slice = %hash{ 'a', 'c' }; # Now %slice is (a => 1, c => 3)
my %hash = (a => 1, b => 2, c
=> 3); my @slice = %hash{ 'a', 'd', 'a' }; # Now @slice is # (a => 1, d => undef, a => 1)
my @array = qw[ foo bar baz quux ]; my
@slice = %array[ 1, 3 ]; # @slice is (1 => "bar", 3 => "quux")
my $record = { artist => $album{artist}, title => $album{title},
tracks => $album{tracks}, year => $album{edition}{year}, label => $album{edition}{lable}, };
my $record = { artist => $album{artist}, title => $album{title},
tracks => $album{tracks}, year => $album{edition}{year}, label => $album{edition}{lable}, };
my $record = { artist => $album{artist}, title => $album{title},
tracks => $album{tracks}, year => $album{edition}{year}, label => $album{edition}{label}, };
my $record = { %album{qw( artist title tracks )}, year
=> $album{edition}{year}, label => $album{edition}{label}, };
# Your mission: get a slice of values # from
$hashref->{x} my $hashref = { x => { ... } };
# Your mission: get a slice of values # from
$hashref->{x} my $hashref = { x => { ... } }; $hashref->{x}{ k1, k2 } #1
# Your mission: get a slice of values # from
$hashref->{x} my $hashref = { x => { ... } }; $hashref->{x}{ k1, k2 } #1
# Your mission: get a slice of values # from
$hashref->{x} my $hashref = { x => { ... } }; $hashref->{x}{ k1, k2 } #1 @{ $hashref->{x} }->{ k1, k2 } #2
# Your mission: get a slice of values # from
$hashref->{x} my $hashref = { x => { ... } }; $hashref->{x}{ k1, k2 } #1 @{ $hashref->{x} }->{ k1, k2 } #2
# Your mission: get a slice of values # from
$hashref->{x} my $hashref = { x => { ... } }; $hashref->{x}{ k1, k2 } #1 @{ $hashref->{x} }->{ k1, k2 } #2 @{ $hashref->{x}{ k1, k2 } } #3
# Your mission: get a slice of values # from
$hashref->{x} my $hashref = { x => { ... } }; $hashref->{x}{ k1, k2 } #1 @{ $hashref->{x} }->{ k1, k2 } #2 @{ $hashref->{x}{ k1, k2 } } #3
# Your mission: get a slice of values # from
$hashref->{x} my $hashref = { x => { ... } }; $hashref->{x}{ k1, k2 } #1 @{ $hashref->{x} }->{ k1, k2 } #2 @{ $hashref->{x}{ k1, k2 } } #3 @{ $hashref->{x} }{ k1, k2} #4
my $record = { %album{qw( artist title tracks )}, year
=> $album{edition}{year}, label => $album{edition}{label}, };
my $record = { %album{qw( artist title tracks )}, $album->{edition}->%{
qw(year label) } );
Postfix Dereferencing (from v5.20.0)
push $sess->{user}->logins , @{ $queue->{unflushed}->logins }; process(@{ $queue->{unhandled}->jobs }); map
{ $_ > $#{$in[0]} } @{$job->input}
push $sess->{user}->logins->@* , @{ $queue->{unflushed}->logins }; process(@{ $queue->{unhandled}->jobs }); map
{ $_ > $#{$in[0]} } @{$job->input}
push $sess->{user}->logins->@* , $queue->{unflushed}->logins->@*; process(@{ $queue->{unhandled}->jobs }); map { $_
> $#{$in[0]} } @{$job->input}
push $sess->{user}->logins->@* , $queue->{unflushed}->logins->@*; process($queue->{unhandled}->jobs->@*); map { $_ > $#{$in[0]}
} @{$job->input}
push $sess->{user}->logins->@* , $queue->{unflushed}->logins->@*; process($queue->{unhandled}->jobs->@*); map { $_ > $#{$in[0]}
} $job->input->@*
push $sess->{user}->logins->@* , $queue->{unflushed}->logins->@*; process($queue->{unhandled}->jobs->@*); map { $_ > $in[0]->$#*
} $job->input->@*
@{ expr } ⇢ ⇢ ⇢ ⇢ expr->@* %{ expr
} ⇢ ⇢ ⇢ ⇢ expr->%* ${ expr } ⇢ ⇢ ⇢ ⇢ expr->$* &{ expr } ⇢ ⇢ ⇢ ⇢ expr->&* *{ expr } ⇢ ⇢ ⇢ ⇢ expr->** $#{ expr } ⇢ ⇢ ⇢ ⇢ expr->$#*
@{ expr }[1,2,3] ⇢ expr->@[1,2,3] @{ expr }{k1,k2} ⇢ expr->@{k1,k2}
%{ expr }[1,2,3] ⇢ expr->%[1,2,3] %{ expr }{k1,k2} ⇢ expr->%{k1,k2} *{ expr }{ARRAY} ⇢ expr->*{ARRAY}
say "Items: $arrayref->@*[0,1]" say "Content: $body_ref->$*"
Postfix Dereferencing (use experimental 'postderef')
reference aliasing (from v5.22.0)
None
my @array = (1, 2, 3, 4);
my @array = (1, 2, 3, 4); my $ref =
\@array;
my @array = (1, 2, 3, 4); my $ref =
\@array;
my @array = (1, 2, 3, 4); my $ref =
\@array; shift @$ref;
my @array = (1, 2, 3, 4); my $ref =
\@array; shift @$ref;
my @array = (1, 2, 3, 4); my $ref =
\@array; shift @$ref; say "@array";
my @array = (1, 2, 3, 4); my $ref =
\@array; shift @$ref; say "@array";
my @array = (1, 2, 3, 4); my $ref =
\@array; shift @$ref; say "@array"; 2 3 4
my @array = (1, 2, 3, 4); my @copy =
@array; shift @copy; say "@array"; 1 2 3 4
my @array = (1, 2, 3, 4); \my @alias =
\@array; shift @alias; say "@array"; 2 3 4
my @array = (1, 2, 3, 4); \my @alias =
\@array; shift @alias; say "@array"; 2 3 4
my @todo = ({ what => 'eat pie', when =>
'right now' }, { what => 'eat cake', when => 'quite soon' }); for my $item (@todo) { say "Please $item->{what} $item->{when}." }
my @todo = ({ what => 'eat pie', when =>
'right now' }, { what => 'eat cake', when => 'quite soon' }); for my $item (@todo) { say "Please $item->{what} $item->{when}." }
my @todo = ({ what => 'eat pie', when =>
'right now' }, { what => 'eat cake', when => 'quite soon' }); for \my %todo (@todo) { say "Please $item{what} $item{when}." }
my $href = $some->awful->[0]->{chain}; for my $key (keys %$hash) {
say "$key: $hash->{$key}"; }
\my %href = $some->awful->[0]->{chain}; for my $key (keys %hash) {
say "$key: $hash{$key}"; }
{ \my %href = $some->awful->[0]->{chain}; for my $key (keys %hash)
{ say "$key: $hash{$key}"; } }
for \my %hash ($some->awful->[0]->{chain}) { for my $key (keys %hash)
{ say "$key: $hash{$key}"; } }
reference aliasing (use experimental 'refaliasing')
fasterization
fasterization my @array = split /.../, $string;
fasterization package MyClass { sub new { ... } }
my $obj = MyClass->new;
fasterization package MyClass { sub new { ... } }
my $obj = MyClass->new; $obj->UNIVERSAL::isa( ... );
fasterization package MyClass { sub new { ... } }
my $obj = MyClass->new; $obj->SUPER::new( ... );
fasterization OP_METHOP
fasterization OP_MULTIDEREF
fasterization my $x = $a->[0]{one}[2]{three}{four}[5];
fasterization my $x = $a
fasterization my $x = $a->[0]
fasterization my $x = $a->[0]{one}
fasterization my $x = $a->[0]{one}[2]
fasterization my $x = $a->[0]{one}[2]{three}
fasterization my $x = $a->[0]{one}[2]{three}{four}
fasterization my $x = $a->[0]{one}[2]{three}{four}[5];
fasterization my $x = $a
fasterization my $x = $a->[0]{one}[2]{three}{four}[5];
NaN nananananananananana
None
==> x (Inf)
==> x (Inf) 'Inf'
==> x (Inf) 'Inf' ==> x (Inf + 0)
==> x (Inf) 'Inf' ==> x (Inf + 0) 'Inf'
==> x (Inf) 'Inf' ==> x (Inf + 0) 'Inf'
==> x (Inf + Inf)
==> x (Inf) 'Inf' ==> x (Inf + 0) 'Inf'
==> x (Inf + Inf) 'Inf'
==> x (Inf) 'Inf' ==> x (Inf + 0) 'Inf'
==> x (Inf + Inf) 'Inf' ==> x (Inf - Inf)
==> x (Inf) 'Inf' ==> x (Inf + 0) 'Inf'
==> x (Inf + Inf) 'Inf' ==> x (Inf - Inf) 'NaN'
==> x (Inf) 'Inf' ==> x (Inf + 0) 'Inf'
==> x (Inf + Inf) 'Inf' ==> x (Inf - Inf) 'NaN' ==> x (Inf * 0)
==> x (Inf) 'Inf' ==> x (Inf + 0) 'Inf'
==> x (Inf + Inf) 'Inf' ==> x (Inf - Inf) 'NaN' ==> x (Inf * 0) 'NaN'
==> x (Inf) 'Inf' ==> x (Inf + 0) 'Inf'
==> x (Inf + Inf) 'Inf' ==> x (Inf - Inf) 'NaN' ==> x (Inf * 0) 'NaN' ==> x (NaN + NaN)
==> x (Inf) 'Inf' ==> x (Inf + 0) 'Inf'
==> x (Inf + Inf) 'Inf' ==> x (Inf - Inf) 'NaN' ==> x (Inf * 0) 'NaN' ==> x (NaN + NaN) 'NaN'
==> x (Inf) 'Inf' ==> x (Inf + 0) '#1.INF'
==> x (Inf + Inf) '#1.INF' ==> x (Inf - Inf) '#1.IND' ==> x (Inf * 0) '#1.IND' ==> x (NaN + NaN) '#1.QNAN'
==> x (Inf) 'Inf' ==> x (Inf + 0) 'Inf'
==> x (Inf + Inf) 'Inf' ==> x (Inf - Inf) 'NaN' ==> x (Inf * 0) 'NaN' ==> x (NaN + NaN) 'NaN'
None
==> x (0 + "Nan")
==> x (0 + "Nan") 'NaN'
==> x (0 + "Nan") 'NaN' ==> x (0 +
"Nancy")
==> x (0 + "Nan") 'NaN' ==> x (0 +
"Nancy") 'NaN'
==> x (0 + "Nan") 'NaN' ==> x (0 +
"Nancy") 'NaN' ==> x (0 + "123abc")
==> x (0 + "Nan") 'NaN' ==> x (0 +
"Nancy") 'NaN' ==> x (0 + "123abc") 123
==> x (0 + "Nan") 'NaN' ==> x (0 +
"Nancy") 'NaN' ==> x (0 + "123abc") Argument "123abc" isn't numeric 123
==> x (0 + "Nan") 'NaN' ==> x (0 +
"Nancy") 'NaN' ==> x (0 + "123abc") Argument "123abc" isn't numeric 123 ==> x (0 + "Nancy, this is Susan. Susan, this is Nancy.\n\n...") 'NaN'
==> x (0 + "Nan") 'NaN' ==> x (0 +
"Nancy") Argument "Nancy" isn't numeric 'NaN' ==> x (0 + "123abc") Argument "123abc" isn't numeric 123 ==> x (0 + "Nancy, this is Susan. Susan, this is Nancy.\n\n...") Argument "Nancy, this is Susan... 'NaN'
not not a numbers
hex floats $x = 1.23e4;
hex floats $x = 0xE.A3p4;
hex floats $x = 1.23e4;
hex floats $x = 1.23e4; $x = ( 1 +
23 / 100 ) * 10**4;
hex floats $x = 0xE.A3p4;
hex floats $x = 0xE.A3p4; $x = ( 0xE +
0xA3 / 0x100 ) * 2**4;
hex floats $x = 0xE.A3p4;
hex floats $x = 0xE.A3p4; # 234.1875
hex floats $x = 0xE.A3p4; # 234.1875 printf "%x", $x;
# "ea"
hex floats $x = 0xE.A3p4; # 234.1875 printf "%x", $x;
# "ea" printf "%a", $x; # 0x1.d46p+7
hex floats $x = 0xE.A3p4; # 234.1875 printf "%x", $x;
# "ea" printf "%a", $x; # 0x1.d46p+7 :-)
speaking of numbers and not-numbers
None
NAME!
NAME! THAT!
NAME! THAT! OPERATOR!
name that operator
name that operator $x + $y
name that operator $x + $y $x - $y
name that operator $x + $y $x - $y $x
* $y
name that operator $x + $y $x - $y $x
* $y $x / $y
name that operator
name that operator $x eq $y
name that operator $x eq $y $x ne $y
name that operator $x eq $y $x ne $y $x
lt $y
name that operator $x eq $y $x ne $y $x
lt $y $x gt $y
name that operator
name that operator $x ~~ $y
name that operator
name that operator $x && $y
name that operator $x && $y $x || $y
name that operator $x && $y $x || $y $x
xor $y
name that operator
name that operator $x & $y
name that operator $x & $y $x | $y
name that operator $x & $y $x | $y $x
^ $y
name that operator $x & $y $x | $y $x
^ $y ~ $x
bitwise operator types
bitwise operator types $num1 & $num2
bitwise operator types $num1 & $num2 $str1 & $str2
bitwise operator types $num1 & $num2 $str1 & $str2 $num1
& $str2
bitwise operator types $num1 & $num2 $str1 & $str2 $num1
& $str2 $str1 & $num2
bitwise operator types
bitwise operator types use experimental 'bitwise';
bitwise operator types use experimental 'bitwise';
bitwise operator types use experimental 'bitwise'; $x & $y
bitwise operator types use experimental 'bitwise'; $x & $y $x
&. $y
bitwise operator types
bitwise operator types use experimental 'bitwise';
bitwise operator types use experimental 'bitwise';
bitwise operator types use experimental 'bitwise'; $x | $y
bitwise operator types use experimental 'bitwise'; $x | $y $x
|. $y
bitwise operator types
bitwise operator types use experimental 'bitwise';
bitwise operator types use experimental 'bitwise';
bitwise operator types use experimental 'bitwise'; $x ^ $y
bitwise operator types use experimental 'bitwise'; $x ^ $y $x
^. $y
bitwise operator types
bitwise operator types use experimental 'bitwise';
bitwise operator types use experimental 'bitwise';
bitwise operator types use experimental 'bitwise'; ~ $x
bitwise operator types use experimental 'bitwise'; ~ $x ~. $x
bitstring ops
bitstring ops use experimental 'bitwise';
bitstring ops use experimental 'bitwise';
bitstring ops use experimental 'bitwise'; my $x = "" &.
"";
bitstring ops use experimental 'bitwise'; my $x = "" &.
""; say $x;
(@) (from v5.20.0)
sub add { my ($x, $y) = @_; return $x
+ $y; }
sub add ($x, $y) { return $x + $y; }
sub add ($x, $y = 0) { return $x +
$y; }
sub add ($x = 0, $y = 0) { return
$x + $y; }
sub add ($x = 0, $y = return $x) {
return $x + $y; }
sub add ($x= (return 0), $y= return $x) { return
$x + $y; }
sub add ( $x = (return 0), $y = return
$x + do { my $dbh = DBI->connect($DSN); my ($y) = $dbh->selectrow_array( "SELECT rhs FROM op_defaults WHERE op = '+'" ); $y } ) { return $x + $y; }
sub mult_many { my ($factor, @inputs) = @_; return map
{; $factor * $_ } @inputs }
sub mult_many ($factor, @inputs) { return map {; $factor *
$_ } @inputs }
sub send_mail ($self, $mail, %arg) { $self->smtp->deliver( $mail, %arg{ 'from',
'to' }, ); }
sub each ($code, @rest) :prototype(&@) { $code->($_) for @rest; }
each { say } (1, 2, 3);
sub each :prototype(&@) ($code, @rest) { $code->($_) for @rest; }
each { say } (1, 2, 3);
sub process_queue { my ($self, $arg, $queue) = @_; for
my $item ( @$queue ) { debug($item->{name}) if $arg->{debug}; $self->accept($item->{job_id}); } }
sub process_queue ($self, $arg, $queue) { for my $item (
@$queue ) { debug($item->{name}) if $arg->{debug}; $self->accept($item->{job_id}); } }
sub process_queue ($self, $arg, $queue) { for \my %item (
@$queue ) { debug($item{name}) if $arg->{debug}; $self->accept($item{job_id}); } }
sub process_queue ($self, $arg, $queue) { for \my %item (
@$queue ) { debug($item{name}) if $arg->{debug}; $self->accept($item{job_id}); } }
sub process_queue ($self, \%arg, \@queue) { for \my %item (
@queue ) { debug($item{name}) if $arg{debug}; $self->accept($item{job_id}); } }
Perl 5.22
Perl 5.22 available now!
Perl 5.22
Perl 5.22 available now!
Perl 5.22 available now! higher version number than ever before!
Any Questions?
Thank you!
Perl 5.24?
warnings
warnings
warnings •use warnings;
warnings •use warnings; •use warnings 'all';
warnings •use warnings; •use warnings 'all'; •use warnings 'FATAL';
warnings •use warnings; •use warnings 'all'; •use warnings 'FATAL'; •use
warnings FATAL => 'all';
warnings use warnings; my $re = qr/(?:-)xyz/;
warnings use warnings; my $re = qr/(?:-)xyz/; Probably-accidental smiley found
in regexp at line 2
None
massive mailing list thread about :-)
massive mailing list thread about :-)
massive mailing list thread about :-) which is :-(
warnings
warnings •use warnings;
warnings •use warnings; •use warnings 'default';
warnings •use warnings; •use warnings 'default'; •use warnings 'FATAL';
warnings •use warnings; •use warnings 'default'; •use warnings 'FATAL'; •use
warnings FATAL => 'default';
warnings use warnings; my $re = qr/(?:-)xyz/;
warnings use warnings qw(default smileys); my $re = qr/(?:-)xyz/; Probably-accidental
smiley found in regexp at line 2
warnings use warnings 'all'; my $re = qr/(?:-)xyz/; Probably-accidental smiley
found in regexp at line 2
strictures
strictures use strict; while ( my $event = next_event )
{ print { $logfile } "$event\n"; }
strictures # logfile.txt Garbo::Event=HASH(0x03941ae0f) Garbo::Event=HASH(0x03944a30f) Garbo::Event=HASH(0x03941af0f) Garbo::Event=HASH(0x031411eff) Garbo::Event=HASH(0x039110020) Garbo::Event=HASH(0x03941ae0f)
strictures use strict 'stringification'; while ( my $event = next_event
) { print { $logfile } "$event\n"; } Can't stringify a reference with no overloading while "strict stringification" in use