Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Perl 5.28 new features

5,064 views

Published on

Exciting developments in Perl

Published in: Technology

Perl 5.28 new features

  1. 1. ThePerlReview•www.theperlreview.com Perlv5.28NewFeatures Perl 5.28 New Features www.perl.org Alpine Perl Workshop 2016 • brian d foy
  2. 2. ThePerlReview•www.theperlreview.com Perlv5.28NewFeatures Auto referencing use feature qw(auto_ref); no warnings qw(experimental::autoref); foo( %hash, @array ); sub foo ( %hash, @array ) { … }
  3. 3. ThePerlReview•www.theperlreview.com Perlv5.28NewFeatures Fancier signatures use 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] ) { … }
  4. 4. ThePerlReview•www.theperlreview.com Perlv5.28NewFeatures Distributed map / grep use feature qw(parallel); no warnings qw(experimental::parallel); @{^PERL_WORKER_POOL} = ‘192.168.1/8’; my @transformed = map { foo() } @array; sub foo :distributive { … }
  5. 5. ThePerlReview•www.theperlreview.com Perlv5.28NewFeatures Better Safe use 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); … }
  6. 6. ThePerlReview•www.theperlreview.com Perlv5.28NewFeatures Three-state TAP ok 1 - 2 + 2 = 4 ok 2 - 2 - 2 = 0 not 3 - 2 + 2 = 5 meh 4 - documentation is correct ok 5 - Another test passed
  7. 7. ThePerlReview•www.theperlreview.com Perlv5.28NewFeatures Close enough comparators 7 =? 8 # True 7 !=? 9 # False 7 >+ 6 # False 7 >+ 3 # True 7 >++ 3 # False 7 <+ 9 # False 7 <+ 14 # True 7 <++ 14 # False
  8. 8. ThePerlReview•www.theperlreview.com Perlv5.28NewFeatures 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 )
  9. 9. ThePerlReview•www.theperlreview.com Perlv5.28NewFeatures Upgradable = my $scalar =^ ( 1,, 2,, 3,, 4,, ); say $scalar; # fatal, no $scalar say “@scalar”; # 1 2 3 4 my @array =^ ( cat >=> Buster ); # %array use feature qw(upgrade_assign);
  10. 10. ThePerlReview•www.theperlreview.com Perlv5.28NewFeatures Yada Yada Alotta use feature qw(alotta); no warnings qw(experimental::alotta); while (<>) { … }
  11. 11. ThePerlReview•www.theperlreview.com Perlv5.28NewFeatures Better Git Interop •Compiler recognizes conflict markers •Will run both versions •Chooses version with right answer
  12. 12. ThePerlReview•www.theperlreview.com Perlv5.28NewFeatures 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.”

×