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
59
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
80
1.21 Gigawatts
rjbs
3
510
Perl 5: Postcards from the Edge
rjbs
1
970
Perl: Today, Tomorrow, and Christmas
rjbs
0
110
Perl 5.16 for the Working Programmer
rjbs
0
79
Perl 5.14 for Pragmatists
rjbs
0
69
Perl 5.12 for Everyday Use
rjbs
0
190
Dist::Zilla — raaaaaaaaar!
rjbs
1
490
Validating Data Everywhere with Rx
rjbs
0
130
Other Decks in Programming
See All in Programming
開発効率向上のためのリファクタリングの一歩目の選択肢 ~コード分割~ / JJUG CCC 2024 Fall
ryounasso
0
440
受け取る人から提供する人になるということ
little_rubyist
0
210
CPython 인터프리터 구조 파헤치기 - PyCon Korea 24
kennethanceyer
0
250
Contemporary Test Cases
maaretp
0
120
詳細解説! ArrayListの仕組みと実装
yujisoftware
0
560
どうして僕の作ったクラスが手続き型と言われなきゃいけないんですか
akikogoto
1
100
Jakarta EE meets AI
ivargrimstad
0
280
A Journey of Contribution and Collaboration in Open Source
ivargrimstad
0
650
Amazon Qを使ってIaCを触ろう!
maruto
0
380
【Kaigi on Rails 2024】YOUTRUST スポンサーLT
krpk1900
1
320
みんなでプロポーザルを書いてみた
yuriko1211
0
230
ActiveSupport::Notifications supporting instrumentation of Rails apps with OpenTelemetry
ymtdzzz
1
210
Featured
See All Featured
Imperfection Machines: The Place of Print at Facebook
scottboms
264
13k
Code Review Best Practice
trishagee
64
17k
How To Stay Up To Date on Web Technology
chriscoyier
788
250k
RailsConf 2023
tenderlove
29
900
Building Applications with DynamoDB
mza
90
6.1k
Ruby is Unlike a Banana
tanoku
96
11k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
356
29k
Designing for Performance
lara
604
68k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
Testing 201, or: Great Expectations
jmmastey
38
7.1k
Mobile First: as difficult as doing things right
swwweet
222
8.9k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
33k
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