SlideShare uma empresa Scribd logo
1 de 20
Baixar para ler offline
Perl v5.26
New
Features
AmsterdamX.pm, 8 Jun 2017
Tunisian Camels (2010), from Ray on Flickr
ThePerlReview•www.theperlreview.com
Perlv5.26NewFeatures
scalar %hash
ThePerlReview•www.theperlreview.com
Perlv5.26NewFeatures
The key count
• A hash in scalar context returned “hash
statistics”
my %h = (a=>1, b=>2);
say scalar %h; # ‘2/8’
• Everyone expected it to be the number of keys
• Now that’s what they get.
my %h = (a=>1, b=>2);
say scalar %h; # 2
ThePerlReview•www.theperlreview.com
Perlv5.26NewFeatures
POSIX::tmpnam
ThePerlReview•www.theperlreview.com
Perlv5.26NewFeatures
use File::Temp qw/ tempfile tempdir /;
$fh = tempfile();
($fh, $filename) = tempfile();
($fh, $filename) = tempfile(
$template, DIR => $dir);
($fh, $filename) = tempfile(
$template, SUFFIX => '.dat');
($fh, $filename) = tempfile(
$template, TMPDIR => 1 );
ThePerlReview•www.theperlreview.com
Perlv5.26NewFeatures
{
ThePerlReview•www.theperlreview.com
Perlv5.26NewFeatures
Regexes are messier
• N{NAME}, x{ABCD}, p{PROPERTY},
P{PROPERTY}, b{…}, B{…}, a{MIN,MAX},
and so on
• New things are probably on the way
• So, every { is now special and not literal
• Some old tools might break
ThePerlReview•www.theperlreview.com
Perlv5.26NewFeatures
/xx
ThePerlReview•www.theperlreview.com
Perlv5.26NewFeatures
More Meaninglessness
• /x makes most whitespace in a regex
insignificant
• And, you can add comments inside regex
• Except in a character class [ a b c ]
• Or [ a #comment b c ]
• Previously, Perl ignored additional /x
• Maybe you added /xxx to honor Amsterdam.
• Now you can’t.
• /xx now applies the rules inside a char class
ThePerlReview•www.theperlreview.com
Perlv5.26NewFeatures
Apple Part Number
my $string = ' Z007LL/A';
my $pattern = qr/
A
# M = First sale, F = Refurbished, P = Personalized
[ M F P ]
# probably not all these letters here
[ A-Z ]
d+
(?: # country codes
LL |
[ FBEJTXYC ]
)
/
[ A B C ] # revision
z
/xx;
say $string =~ $pattern ? 'Matched' : 'Missed';
ThePerlReview•www.theperlreview.com
Perlv5.26NewFeatures
Hopes for /xxx
(?:L [
A # Colombia, Ecuador, El Salvador, … Peru
E # Argentina
L # US
Z # Chile, Paraguay, Uruguay
]
|
[
F # France
B # Ireland, UK
E # Mexico
J # Japan
T # Italy
X # Australia, New Zealand
Y # Spain
C # Canada
]
)
ThePerlReview•www.theperlreview.com
Perlv5.26NewFeatures
Indented Heredocs
ThePerlReview•www.theperlreview.com
Perlv5.26NewFeatures
my $string = <<~“HERE";
This is the first line
This is the second line
HERE
This is the first line
This is the second line
ThePerlReview•www.theperlreview.com
Perlv5.26NewFeatures
my $string = <<~“HERE";
This is the first line
This is the second line
HERE
This is the first line
This is the second line
ThePerlReview•www.theperlreview.com
Perlv5.26NewFeatures
No . in @INC
ThePerlReview•www.theperlreview.com
Perlv5.26NewFeatures
More Securitiness
• What’s that . anyway?
• This doesn’t mean that you are safe
• CPAN tested, but not DarkPAN tested
• do warns when it fails to load a file from .
• You can disable this, but I won’t tell you how
ThePerlReview•www.theperlreview.com
Perlv5.26NewFeatures
@{^CAPTURE}
ThePerlReview•www.theperlreview.com
Perlv5.26NewFeatures
List of Captures
• %{^CAPTURE} is %+ (named captures)
• %{^CAPTURE_ALL} is %- (all named captures)
• @{^CAPTURE} is the cool one.
• ${^CAPTURE}[INDEX] is the numbered capture
minus 1
ThePerlReview•www.theperlreview.com
Perlv5.26NewFeatures
sub match_it_1 ( $rx, $string ) {
$string =~ $rx;
say "$1•$2•$3"; # Hoping there's three
}
sub match_it_2 ( $rx, $string ) {
$string =~ $rx;
say join '•', map {
substr $string, $-[$_], $+[$_]-$-[$_]
} 1 .. $#-;
}
sub match_it_3 ( $rx, $string ) {
$string =~ $rx;
local $" = '•';
say "@{^CAPTURE}";
}
ThePerlReview•www.theperlreview.com
Perlv5.26NewFeatures
Questions

Mais conteúdo relacionado

Mais procurados

Building Better Applications with Data::Manager
Building Better Applications with Data::ManagerBuilding Better Applications with Data::Manager
Building Better Applications with Data::Manager
Jay Shirley
 
Smolder @Silex
Smolder @SilexSmolder @Silex
Smolder @Silex
Jeen Lee
 
for this particular program how do i create the input innotepad 1st ? #includ...
for this particular program how do i create the input innotepad 1st ? #includ...for this particular program how do i create the input innotepad 1st ? #includ...
for this particular program how do i create the input innotepad 1st ? #includ...
hwbloom59
 

Mais procurados (20)

10 Catalyst Tips
10 Catalyst Tips10 Catalyst Tips
10 Catalyst Tips
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to Perl
 
dotCloud and go
dotCloud and godotCloud and go
dotCloud and go
 
Zen: Building Maintainable Catalyst Applications
Zen: Building Maintainable Catalyst ApplicationsZen: Building Maintainable Catalyst Applications
Zen: Building Maintainable Catalyst Applications
 
Building Better Applications with Data::Manager
Building Better Applications with Data::ManagerBuilding Better Applications with Data::Manager
Building Better Applications with Data::Manager
 
R版Getopt::Longを作ってみた
R版Getopt::Longを作ってみたR版Getopt::Longを作ってみた
R版Getopt::Longを作ってみた
 
Command Liner with Scala
Command Liner with ScalaCommand Liner with Scala
Command Liner with Scala
 
JSLab. Домников Виталий. "ES6 генераторы и Koa.js"
JSLab. Домников Виталий. "ES6 генераторы и Koa.js"JSLab. Домников Виталий. "ES6 генераторы и Koa.js"
JSLab. Домников Виталий. "ES6 генераторы и Koa.js"
 
Adventures in Optimization
Adventures in OptimizationAdventures in Optimization
Adventures in Optimization
 
Phpbase
PhpbasePhpbase
Phpbase
 
Perl Sucks - and what to do about it
Perl Sucks - and what to do about itPerl Sucks - and what to do about it
Perl Sucks - and what to do about it
 
TDDBC お題
TDDBC お題TDDBC お題
TDDBC お題
 
Smolder @Silex
Smolder @SilexSmolder @Silex
Smolder @Silex
 
Session8
Session8Session8
Session8
 
TRunner
TRunnerTRunner
TRunner
 
Visualizing ORACLE performance data with R @ #C16LV
Visualizing ORACLE performance data with R @ #C16LVVisualizing ORACLE performance data with R @ #C16LV
Visualizing ORACLE performance data with R @ #C16LV
 
10 tips for making Bash a sane programming language
10 tips for making Bash a sane programming language10 tips for making Bash a sane programming language
10 tips for making Bash a sane programming language
 
for this particular program how do i create the input innotepad 1st ? #includ...
for this particular program how do i create the input innotepad 1st ? #includ...for this particular program how do i create the input innotepad 1st ? #includ...
for this particular program how do i create the input innotepad 1st ? #includ...
 
for this particular program how do i create the input innotepad 1st ?#include...
for this particular program how do i create the input innotepad 1st ?#include...for this particular program how do i create the input innotepad 1st ?#include...
for this particular program how do i create the input innotepad 1st ?#include...
 
Git Sensitive Data
Git Sensitive DataGit Sensitive Data
Git Sensitive Data
 

Semelhante a Perl v5.26 Features (AmsterdamX.pm)

Test in action week 2
Test in action   week 2Test in action   week 2
Test in action week 2
Yi-Huan Chan
 

Semelhante a Perl v5.26 Features (AmsterdamX.pm) (20)

SPL, not a bridge too far
SPL, not a bridge too farSPL, not a bridge too far
SPL, not a bridge too far
 
Loops and Unicorns - The Future of the Puppet Language - PuppetConf 2013
Loops and Unicorns - The Future of the Puppet Language - PuppetConf 2013Loops and Unicorns - The Future of the Puppet Language - PuppetConf 2013
Loops and Unicorns - The Future of the Puppet Language - PuppetConf 2013
 
Test in action week 2
Test in action   week 2Test in action   week 2
Test in action week 2
 
PHP Conference Asia 2016
PHP Conference Asia 2016PHP Conference Asia 2016
PHP Conference Asia 2016
 
Php Crash Course - Macq Electronique 2010
Php Crash Course - Macq Electronique 2010Php Crash Course - Macq Electronique 2010
Php Crash Course - Macq Electronique 2010
 
Testing Code and Assuring Quality
Testing Code and Assuring QualityTesting Code and Assuring Quality
Testing Code and Assuring Quality
 
How CPAN Testers helped me improve my module
How CPAN Testers helped me improve my moduleHow CPAN Testers helped me improve my module
How CPAN Testers helped me improve my module
 
PHP-Overview.ppt
PHP-Overview.pptPHP-Overview.ppt
PHP-Overview.ppt
 
PHP-01-Overview.ppt
PHP-01-Overview.pptPHP-01-Overview.ppt
PHP-01-Overview.ppt
 
perl course-in-mumbai
 perl course-in-mumbai perl course-in-mumbai
perl course-in-mumbai
 
perl course-in-mumbai
perl course-in-mumbaiperl course-in-mumbai
perl course-in-mumbai
 
Regular expressions, Session and Cookies by Dr.C.R.Dhivyaa Kongu Engineering ...
Regular expressions, Session and Cookies by Dr.C.R.Dhivyaa Kongu Engineering ...Regular expressions, Session and Cookies by Dr.C.R.Dhivyaa Kongu Engineering ...
Regular expressions, Session and Cookies by Dr.C.R.Dhivyaa Kongu Engineering ...
 
UNIT IV (4).pptx
UNIT IV (4).pptxUNIT IV (4).pptx
UNIT IV (4).pptx
 
Automated code audits
Automated code auditsAutomated code audits
Automated code audits
 
WebAssembly. Neither Web Nor Assembly, All Revolutionary
WebAssembly. Neither Web Nor Assembly, All RevolutionaryWebAssembly. Neither Web Nor Assembly, All Revolutionary
WebAssembly. Neither Web Nor Assembly, All Revolutionary
 
PHP_Lecture.pdf
PHP_Lecture.pdfPHP_Lecture.pdf
PHP_Lecture.pdf
 
Preparing for the next PHP version (5.6)
Preparing for the next PHP version (5.6)Preparing for the next PHP version (5.6)
Preparing for the next PHP version (5.6)
 
Hiveminder - Everything but the Secret Sauce
Hiveminder - Everything but the Secret SauceHiveminder - Everything but the Secret Sauce
Hiveminder - Everything but the Secret Sauce
 
Perl 101
Perl 101Perl 101
Perl 101
 
Object Oriented PHP - PART-2
Object Oriented PHP - PART-2Object Oriented PHP - PART-2
Object Oriented PHP - PART-2
 

Mais de brian d foy

The Whitespace in the Perl Community
The Whitespace in the Perl CommunityThe Whitespace in the Perl Community
The Whitespace in the Perl Community
brian d foy
 
Advanced modulinos
Advanced modulinosAdvanced modulinos
Advanced modulinos
brian d foy
 

Mais de brian d foy (20)

Conferences for Beginners presentation
Conferences for Beginners presentationConferences for Beginners presentation
Conferences for Beginners presentation
 
20 years in Perl
20 years in Perl20 years in Perl
20 years in Perl
 
The Surprisingly Tense History of the Schwartzian Transform
The Surprisingly Tense History of the Schwartzian TransformThe Surprisingly Tense History of the Schwartzian Transform
The Surprisingly Tense History of the Schwartzian Transform
 
Perl Power Tools - Saint Perl 6
Perl Power Tools - Saint Perl 6Perl Power Tools - Saint Perl 6
Perl Power Tools - Saint Perl 6
 
The Whitespace in the Perl Community
The Whitespace in the Perl CommunityThe Whitespace in the Perl Community
The Whitespace in the Perl Community
 
CPAN Workshop, Chicago 2014
CPAN Workshop, Chicago 2014CPAN Workshop, Chicago 2014
CPAN Workshop, Chicago 2014
 
Parsing JSON with a single regex
Parsing JSON with a single regexParsing JSON with a single regex
Parsing JSON with a single regex
 
Reverse Installing CPAN
Reverse Installing CPANReverse Installing CPAN
Reverse Installing CPAN
 
Advanced modulinos
Advanced modulinosAdvanced modulinos
Advanced modulinos
 
Advanced modulinos trial
Advanced modulinos trialAdvanced modulinos trial
Advanced modulinos trial
 
Bag of tricks
Bag of tricksBag of tricks
Bag of tricks
 
I ❤ CPAN
I ❤ CPANI ❤ CPAN
I ❤ CPAN
 
Tour of the Perl docs
Tour of the Perl docsTour of the Perl docs
Tour of the Perl docs
 
Create and upload your first Perl module to CPAN
Create and upload your first Perl module to CPANCreate and upload your first Perl module to CPAN
Create and upload your first Perl module to CPAN
 
Perl Conferences for Beginners
Perl Conferences for BeginnersPerl Conferences for Beginners
Perl Conferences for Beginners
 
Backward to DPAN
Backward to DPANBackward to DPAN
Backward to DPAN
 
Perl docs {sux|rulez}
Perl docs {sux|rulez}Perl docs {sux|rulez}
Perl docs {sux|rulez}
 
Why I Love CPAN
Why I Love CPANWhy I Love CPAN
Why I Love CPAN
 
What's wrong with the perldocs
What's wrong with the perldocsWhat's wrong with the perldocs
What's wrong with the perldocs
 
Frozen Perl 2011 Keynote
Frozen Perl 2011 KeynoteFrozen Perl 2011 Keynote
Frozen Perl 2011 Keynote
 

Último

+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@
 

Último (20)

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...
 
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
 
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...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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
 
+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...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
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...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 

Perl v5.26 Features (AmsterdamX.pm)