12
The Perl Review • www.theperlreview.com Perl v5.28 New Features Perl 5.28 New Features www.perl.org Alpine Perl Workshop 2016 • brian d foy

Perl 5.28 new features

Embed Size (px)

Citation preview

Page 1: Perl 5.28 new features

The Perl Review • www.theperlreview.com

Perl v5.28 New Features

Perl 5.28New Features

www.perl.org

Alpine Perl Workshop 2016 • brian d foy

Page 2: Perl 5.28 new features

The Perl Review • www.theperlreview.com

Perl v5.28 New Features

Auto referencinguse feature qw(auto_ref);no warnings qw(experimental::autoref);

foo( %hash, @array );

sub foo ( \%hash, \@array ) { … }

Page 3: Perl 5.28 new features

The Perl Review • www.theperlreview.com

Perl v5.28 New Features

Fancier signaturesuse feature qw(signatures);no warnings qw(experimental::signatures);

sub foo ( $date[DateTime] ) { … }sub bar ( $n[Int]/Rat/ ) { … }sub baz ( $n[+&bar] ) { … }sub quux ( $[+&bar|Int] ) { … }

Page 4: Perl 5.28 new features

The Perl Review • www.theperlreview.com

Perl v5.28 New Features

Distributed map / grepuse feature qw(parallel);no warnings qw(experimental::parallel);

@{^PERL_WORKER_POOL} = ‘192.168.1/8’;

my @transformed = map { foo() } @array;

sub foo :distributive { … }

Page 5: Perl 5.28 new features

The Perl Review • www.theperlreview.com

Perl v5.28 New Features

Better Safeuse feature qw(safe);no warnings qw(experimental::safe);

use safe qw(:all);no safe qw(regex networking);

m/…/; # dies at compile time

{ # new READONLY ${^PERL_LEVEL}no safe qw(:level1);…}

Page 6: Perl 5.28 new features

The Perl Review • www.theperlreview.com

Perl v5.28 New Features

Three-state TAP

ok 1 - 2 + 2 = 4ok 2 - 2 - 2 = 0not 3 - 2 + 2 = 5meh 4 - documentation is correctok 5 - Another test passed

Page 7: Perl 5.28 new features

The Perl Review • www.theperlreview.com

Perl v5.28 New Features

Close enough comparators7 =? 8 # True7 !=? 9 # False7 >+ 6 # False7 >+ 3 # True7 >++ 3 # False7 <+ 9 # False 7 <+ 14 # True 7 <++ 14 # False

Page 8: Perl 5.28 new features

The Perl Review • www.theperlreview.com

Perl v5.28 New Features

New array operators

unshift @array, 6; # ( 6 )push @array, 2; # ( 6, 2 )shove @array, 4; # ( 6, 4, 2)cutin @array, 5; # ( 6, 5, 4, 2 )vip @array, 7; # ( 6, 3, 4, 2 )

Page 9: Perl 5.28 new features

The Perl Review • www.theperlreview.com

Perl v5.28 New Features

Upgradable =my $scalar =^ ( 1,, 2,, 3,, 4,, );say $scalar; # fatal, no $scalarsay “@scalar”; # 1 2 3 4

my @array =^ ( cat >=> Buster ); # %array

use feature qw(upgrade_assign);

Page 10: Perl 5.28 new features

The Perl Review • www.theperlreview.com

Perl v5.28 New Features

Yada Yada Alotta

use feature qw(alotta);no warnings qw(experimental::alotta);

while (<>) {…}

Page 11: Perl 5.28 new features

The Perl Review • www.theperlreview.com

Perl v5.28 New Features

Better Git Interop

•Compiler recognizes conflict markers

•Will run both versions

•Chooses version with right answer

Page 12: Perl 5.28 new features

The Perl Review • www.theperlreview.com

Perl v5.28 New Features

Better Diagnostics•“(W+) Warnings turned off in lexical scope, but this warning is really important.”

•“(P) Converting code into another way to do it. Ways to do counter is 3 (2 to go).”

•“(I) Nope. Just, nope.”

•“(0) This program appears to be a waste of time. Exiting.”