SlideShare a Scribd company logo
1 of 51
Download to read offline
Perl 101
An introduction to the Perl programming language

Alex Balhatchet @ Makers Academy, November 2013
Who Am I?
Who’s this guy?
● Alex Balhatchet
● CTO at Nestoria property search engine
● Programming Perl for 12 years
● Hiring, training and mentoring Perl interns
and permanent hires for 4 years
Nestoria
● Property search engine
● Operating in 8 countries, 6 languages
● Serving 1.3 million search requests per day
● 85% Perl, 5% JavaScript, 5% C, 5% Other
Nestoria
Perl History
What is Perl?
Perl 5 is a high-level, general purpose,
interpreted, dynamic programming language.
It was largely inspired by grep, sed, awk, and
C.
It influenced Python, Ruby, and PHP.
So, Perl
● 1.0 released in 1987
● 5.0 released in 1994
● Language is now “Perl 5”
● Perl 6 is a new language separate from, but
related to, Perl 5
So, Perl 5
● Annual releases since 2010
● Perl 5.18 was released May 2013
● Perl 5.20 will be released May 2014
● New releases contain new features, bug
fixes, and performance improvements
Perl Philosophy
TIMTOWTDI
TIMTOWTDI is pronounced “Tim Toady” and is:

There is more than one way to do it
Perl aims to be aggressively non-prescriptivist.
Every problem should have multiple solutions.
Making easy things easy
& hard things possible
This quote comes from the front of Learning
Perl, also known as the Llama.
It goes hand-in-hand with TIMTOWTDI.
Every problem has multiple
solutions implies every problem
has at least one solution :-)
Do What I Mean
Perl’s creator Larry Wall has a linguistics
background, and took some of that with him
when he designed Perl.
Keywords such as “for”, “my”, “defined”, “say”,
“do”, “while”, “if”, “unless”, and “use” all read
quite nicely to English eyes as well as to
programmer eyes.
Low Ambiguity
In many languages this is
acceptable:

In Perl we use different
operators:

puts 1 + 2
puts "a" + "b"

say 1 + 2;
say "a" . "b";

# 3
# "ab"

say "2" + 1;
say "2" . 1;

# 3
# 21

# 3
# "ab"

puts "2" + 1
# !!
in `+': can't convert
Fixnum into String
(TypeError)
Perl Syntax
Variables - Scalars
$foo = 1;

$bar = 3.14195;

$str = "Hello, World!";
Variables - Arrays
@things = (1, 2, 3);

$things[2]; # 3

join(",", @things); # 1,2,3,4
Variables - Hashes
%hash = (
key => "value",
foo => $bar,
thingies => "whatsits",
);
say $hash{key}; # "value"
Variables - Data Structures
$alex_hashref = {
name => {
first => "Alex",
last => "Balhatchet",
},
languages => [
"English", "German", "Perl"
],
};
Conditionals
if ($true) {
say "It’s true!";
}
say "It’s true too!" if $true_two;
Loops
for $i (1 .. 20) {
say $i * $i;
}
while ($line = <STDIN>) {
say length $line;
}
Regular Expressions - Matching
$str = "Hello, Makers Academy!";
if ($str =~ m/makers/i) {
say "matched!";
}
else {
say "no match :-(";
}
Regular Expressions - Matching
$num = -1.23456;
if ($num =~ m/^ [+-]? d+ ([.]d+)? $/x) {
say "looks like a number!";
}
else {
say "that’s no number I ever saw...";
}
Regular Expressions - Substitutions
$str = "Hello, Makers Academy!";
$str =~ s/Makers Academy/Makers!/;
say $str; # Hello, Makers!!
Subroutines
sub add {
($num_a, $num_b) = @_;
return $num_a + $num_b;
}
say add(3, 4);
# 7
say add(-3, 3);
# 0
say add(1/3, 2/3); # 1
Objects
package MyClass;

use MyClass;

sub new {

$Object = MyClass->new();

($class) = @_;
return bless {}, $class;
}
sub add {
($self, $n1, $n2) = @_;
return $n1 + $n2;
}

say $Object->add(123, 456);
Perl Advantages
Perl Advantages
CPAN
CPAN
CPAN stands for Comprehensive Perl Archive
Network, and is a collection of Perl modules.
You can browse CPAN at cpan.org
Today CPAN contains 126,892 Perl modules in
28,607 distributions, written by 11,031 authors,
mirrored on 271 servers.
CPAN Modules
Web Frameworks (Catalyst, Dancer, Mojo)
ORMs (DBIx::Class, Fey, Norma)
Serialization (XML::Simple, JSON)
Maths (Math::Random::MT, Statistics::TTest,
Geo::Distance)
Perl Advantages
Unicode
Unicode
Perl was made with text manipulation in mind,
and has excellent support for Unicode.
All of Perl’s builtin functions, including regular
expressions, are Unicode safe.
Many CPAN modules that deal with text will
also have considered encoding issues.
Unicode Examples
use utf8::all;
$str = "Schwanhäußerstraße";
say $str;

# Schwanhäußerstraße

say length $str;

# 18

$str = uc $str;
say $str;

# SCHWANHÄUSSERSTRASSE

say substr $str, 7, 1;

# Ä

if ($str =~ m/schwanhäußerstraße/i) {
say "I N{HEAVY BLACK HEART} Perl";
}

# I ❤ Perl
Perl Advantages
Testing
Testing
Perl has a big testing culture.
Most CPAN modules have a test suite!
There are also a good number of CPAN
modules to help you with testing your code.
Testing Example
use Test::More tests => 3;

~$ prove -v example.t
example.t ..

ok 1, "1 is true";

1..3
ok 1 - 1 is true

is 1 + 1, 2, "1 + 1 = 2";

ok 2 - 1 + 1 = 2
ok 3 - got expected array

@a = sort (4, 2, 3, 1);

ok

is_deeply(

All tests successful.

@a,
[ 1, 2, 3, 4 ],
"got expected array"
);

Files=1, Tests=3, 0 wallclock
secs ( 0.02 usr 0.00 sys + 0.02
cusr 0.00 csys = 0.04 CPU)
Result: PASS
Perl Advantages
Community
Perl Community
Monthly social meetings (London.pm)
Bi-monthly technical meetings (London.pm)
Free conference (London Perl Workshop)
See the world! YAPC::EU, YAPC::NA, YAPC::
Russia, YAPC::SA, YAPC::Asia, and YAPC::
Australia
Free Resources
http://learn.perl.org
http://modernperlbooks.com
http://blogs.perl.org
http://perldoc.perl.org
Perl Advantages
Jobs
Perl developers are in demand
We are hiring… and so is pretty much every
other Perl company!
http://lokku.com/jobs
http://jobs.perl.org
Perl at Nestoria
Nestoria
Nestoria Listings Processing
● XML parsing
● Geocoding
● Natural language processing
● De-duplication
● Image thumbnailing
The Nestoria Website
● Apache + mod_perl
● Templating with HTML::Mason
● Maketext (and Locale::Maketext) for translations
● Query Analysis / Geographic lookup
● Spell checking and fuzzy matching
● Super fast (90% requests under 200ms)
Other Stuff :-)
● geodata system
● Continuous testing and deployment
● Metrics processing system
● Automated PDF and Excel file “end of month” reports
● Email Alerts
● Average House Prices
Summary
Summary
● Perl has a rich history and an exciting future
● Perl is a straightforward, easy to learn language
● Perl has a lot of advantages (CPAN, Unicode, & Jobs!)
● At Nestoria we’ve shown that Perl can be the foundation
of a highly successful and technically sophisticated
startup business
Thanks!
Questions?
ht Nes
tp to
:// ri
lo a
kk is
u. Hi
co ri
m ng
/jo !
bs

Thanks!
@kaokun
@nestoria

http://github.com/lokku

More Related Content

What's hot

re-frame à la spec
re-frame à la specre-frame à la spec
re-frame à la specKent Ohashi
 
Clojure in real life 17.10.2014
Clojure in real life 17.10.2014Clojure in real life 17.10.2014
Clojure in real life 17.10.2014Metosin Oy
 
Scala in-practice-3-years by Patric Fornasier, Springr, presented at Pune Sca...
Scala in-practice-3-years by Patric Fornasier, Springr, presented at Pune Sca...Scala in-practice-3-years by Patric Fornasier, Springr, presented at Pune Sca...
Scala in-practice-3-years by Patric Fornasier, Springr, presented at Pune Sca...Thoughtworks
 
The Evolution of Scala / Scala進化論
The Evolution of Scala / Scala進化論The Evolution of Scala / Scala進化論
The Evolution of Scala / Scala進化論scalaconfjp
 
Kamailioworld 2018 - Modular and test driven SIP Routing with Lua
Kamailioworld 2018 - Modular and test driven SIP Routing with LuaKamailioworld 2018 - Modular and test driven SIP Routing with Lua
Kamailioworld 2018 - Modular and test driven SIP Routing with LuaSebastian Damm
 
Long Live the Rubyist
Long Live the RubyistLong Live the Rubyist
Long Live the Rubyistbaccigalupi
 
Shooting the Rapids: Getting the Best from Java 8 Streams
Shooting the Rapids: Getting the Best from Java 8 StreamsShooting the Rapids: Getting the Best from Java 8 Streams
Shooting the Rapids: Getting the Best from Java 8 StreamsMaurice Naftalin
 
Deep dive into Xtext scoping local and global scopes explained
Deep dive into Xtext scoping local and global scopes explainedDeep dive into Xtext scoping local and global scopes explained
Deep dive into Xtext scoping local and global scopes explainedHolger Schill
 
Good and Wicked Fairies, and the Tragedy of the Commons: Understanding the Pe...
Good and Wicked Fairies, and the Tragedy of the Commons: Understanding the Pe...Good and Wicked Fairies, and the Tragedy of the Commons: Understanding the Pe...
Good and Wicked Fairies, and the Tragedy of the Commons: Understanding the Pe...Maurice Naftalin
 
Lambda and Stream Master class - part 1
Lambda and Stream Master class - part 1Lambda and Stream Master class - part 1
Lambda and Stream Master class - part 1José Paumard
 
JFokus 50 new things with java 8
JFokus 50 new things with java 8JFokus 50 new things with java 8
JFokus 50 new things with java 8José Paumard
 
Modern Web Development with Perl
Modern Web Development with PerlModern Web Development with Perl
Modern Web Development with PerlDave Cross
 

What's hot (20)

IO Streams, Files and Directories
IO Streams, Files and DirectoriesIO Streams, Files and Directories
IO Streams, Files and Directories
 
re-frame à la spec
re-frame à la specre-frame à la spec
re-frame à la spec
 
Clojure in real life 17.10.2014
Clojure in real life 17.10.2014Clojure in real life 17.10.2014
Clojure in real life 17.10.2014
 
Scala in-practice-3-years by Patric Fornasier, Springr, presented at Pune Sca...
Scala in-practice-3-years by Patric Fornasier, Springr, presented at Pune Sca...Scala in-practice-3-years by Patric Fornasier, Springr, presented at Pune Sca...
Scala in-practice-3-years by Patric Fornasier, Springr, presented at Pune Sca...
 
The Evolution of Scala / Scala進化論
The Evolution of Scala / Scala進化論The Evolution of Scala / Scala進化論
The Evolution of Scala / Scala進化論
 
Kamailioworld 2018 - Modular and test driven SIP Routing with Lua
Kamailioworld 2018 - Modular and test driven SIP Routing with LuaKamailioworld 2018 - Modular and test driven SIP Routing with Lua
Kamailioworld 2018 - Modular and test driven SIP Routing with Lua
 
Long Live the Rubyist
Long Live the RubyistLong Live the Rubyist
Long Live the Rubyist
 
Unix lab
Unix labUnix lab
Unix lab
 
Shooting the Rapids: Getting the Best from Java 8 Streams
Shooting the Rapids: Getting the Best from Java 8 StreamsShooting the Rapids: Getting the Best from Java 8 Streams
Shooting the Rapids: Getting the Best from Java 8 Streams
 
Deep dive into Xtext scoping local and global scopes explained
Deep dive into Xtext scoping local and global scopes explainedDeep dive into Xtext scoping local and global scopes explained
Deep dive into Xtext scoping local and global scopes explained
 
Tml for Laravel
Tml for LaravelTml for Laravel
Tml for Laravel
 
Good and Wicked Fairies, and the Tragedy of the Commons: Understanding the Pe...
Good and Wicked Fairies, and the Tragedy of the Commons: Understanding the Pe...Good and Wicked Fairies, and the Tragedy of the Commons: Understanding the Pe...
Good and Wicked Fairies, and the Tragedy of the Commons: Understanding the Pe...
 
Let's Get to the Rapids
Let's Get to the RapidsLet's Get to the Rapids
Let's Get to the Rapids
 
Linux commands
Linux commandsLinux commands
Linux commands
 
Free your lambdas
Free your lambdasFree your lambdas
Free your lambdas
 
Lambda and Stream Master class - part 1
Lambda and Stream Master class - part 1Lambda and Stream Master class - part 1
Lambda and Stream Master class - part 1
 
Practical Kerberos
Practical KerberosPractical Kerberos
Practical Kerberos
 
JFokus 50 new things with java 8
JFokus 50 new things with java 8JFokus 50 new things with java 8
JFokus 50 new things with java 8
 
Modern Web Development with Perl
Modern Web Development with PerlModern Web Development with Perl
Modern Web Development with Perl
 
700 Tons of Code Later
700 Tons of Code Later700 Tons of Code Later
700 Tons of Code Later
 

Similar to Perl 101

Bioinformatics p1-perl-introduction v2013
Bioinformatics p1-perl-introduction v2013Bioinformatics p1-perl-introduction v2013
Bioinformatics p1-perl-introduction v2013Prof. Wim Van Criekinge
 
Perl 5.10
Perl 5.10Perl 5.10
Perl 5.10acme
 
Whatsnew in-perl
Whatsnew in-perlWhatsnew in-perl
Whatsnew in-perldaoswald
 
Introduction to perl_ a scripting language
Introduction to perl_ a scripting languageIntroduction to perl_ a scripting language
Introduction to perl_ a scripting languageVamshi Santhapuri
 
What we can learn from Rebol?
What we can learn from Rebol?What we can learn from Rebol?
What we can learn from Rebol?lichtkind
 
Introduction to writing readable and maintainable Perl
Introduction to writing readable and maintainable PerlIntroduction to writing readable and maintainable Perl
Introduction to writing readable and maintainable PerlAlex Balhatchet
 
Introduction to Writing Readable and Maintainable Perl (YAPC::EU 2011 Version)
Introduction to Writing Readable and Maintainable Perl (YAPC::EU 2011 Version)Introduction to Writing Readable and Maintainable Perl (YAPC::EU 2011 Version)
Introduction to Writing Readable and Maintainable Perl (YAPC::EU 2011 Version)Alex Balhatchet
 
Bioinformatica 29-09-2011-p1-introduction
Bioinformatica 29-09-2011-p1-introductionBioinformatica 29-09-2011-p1-introduction
Bioinformatica 29-09-2011-p1-introductionProf. Wim Van Criekinge
 
The Essential Perl Hacker's Toolkit
The Essential Perl Hacker's ToolkitThe Essential Perl Hacker's Toolkit
The Essential Perl Hacker's ToolkitStephen Scaffidi
 
An introduction to Raku
An introduction to RakuAn introduction to Raku
An introduction to RakuSimon Proctor
 
Scala final ppt vinay
Scala final ppt vinayScala final ppt vinay
Scala final ppt vinayViplav Jain
 
php fundamental
php fundamentalphp fundamental
php fundamentalzalatarunk
 

Similar to Perl 101 (20)

Bioinformatics p1-perl-introduction v2013
Bioinformatics p1-perl-introduction v2013Bioinformatics p1-perl-introduction v2013
Bioinformatics p1-perl-introduction v2013
 
Perl 5.10
Perl 5.10Perl 5.10
Perl 5.10
 
Whatsnew in-perl
Whatsnew in-perlWhatsnew in-perl
Whatsnew in-perl
 
Perl Moderno
Perl ModernoPerl Moderno
Perl Moderno
 
Introduction to perl_ a scripting language
Introduction to perl_ a scripting languageIntroduction to perl_ a scripting language
Introduction to perl_ a scripting language
 
What we can learn from Rebol?
What we can learn from Rebol?What we can learn from Rebol?
What we can learn from Rebol?
 
Pearl
PearlPearl
Pearl
 
perl lauange
perl lauangeperl lauange
perl lauange
 
Introduction to writing readable and maintainable Perl
Introduction to writing readable and maintainable PerlIntroduction to writing readable and maintainable Perl
Introduction to writing readable and maintainable Perl
 
Introduction to Writing Readable and Maintainable Perl (YAPC::EU 2011 Version)
Introduction to Writing Readable and Maintainable Perl (YAPC::EU 2011 Version)Introduction to Writing Readable and Maintainable Perl (YAPC::EU 2011 Version)
Introduction to Writing Readable and Maintainable Perl (YAPC::EU 2011 Version)
 
Ruby Presentation - Article
Ruby Presentation - ArticleRuby Presentation - Article
Ruby Presentation - Article
 
Bioinformatica 29-09-2011-p1-introduction
Bioinformatica 29-09-2011-p1-introductionBioinformatica 29-09-2011-p1-introduction
Bioinformatica 29-09-2011-p1-introduction
 
Introducing perl6
Introducing perl6Introducing perl6
Introducing perl6
 
The Essential Perl Hacker's Toolkit
The Essential Perl Hacker's ToolkitThe Essential Perl Hacker's Toolkit
The Essential Perl Hacker's Toolkit
 
Starting Out With PHP
Starting Out With PHPStarting Out With PHP
Starting Out With PHP
 
Perl basics for Pentesters
Perl basics for PentestersPerl basics for Pentesters
Perl basics for Pentesters
 
Introduction to Perl
Introduction to PerlIntroduction to Perl
Introduction to Perl
 
An introduction to Raku
An introduction to RakuAn introduction to Raku
An introduction to Raku
 
Scala final ppt vinay
Scala final ppt vinayScala final ppt vinay
Scala final ppt vinay
 
php fundamental
php fundamentalphp fundamental
php fundamental
 

More from Alex Balhatchet

Geocoding the World in Perl YAPC::EU 2014
Geocoding the World in Perl YAPC::EU 2014Geocoding the World in Perl YAPC::EU 2014
Geocoding the World in Perl YAPC::EU 2014Alex Balhatchet
 
Test Kit 2.0 YAPC::EU 2014 Lightning Talk
Test Kit 2.0 YAPC::EU 2014 Lightning TalkTest Kit 2.0 YAPC::EU 2014 Lightning Talk
Test Kit 2.0 YAPC::EU 2014 Lightning TalkAlex Balhatchet
 
Nestoria Dev Blog YAPC::EU 2014 Lightning Talk
Nestoria Dev Blog YAPC::EU 2014 Lightning TalkNestoria Dev Blog YAPC::EU 2014 Lightning Talk
Nestoria Dev Blog YAPC::EU 2014 Lightning TalkAlex Balhatchet
 
Test::Kit 2.0 (London.pm Technical Meeting July 2014)
Test::Kit 2.0 (London.pm Technical Meeting July 2014)Test::Kit 2.0 (London.pm Technical Meeting July 2014)
Test::Kit 2.0 (London.pm Technical Meeting July 2014)Alex Balhatchet
 
App::highlight - a simple grep-like highlighter app
App::highlight - a simple grep-like highlighter appApp::highlight - a simple grep-like highlighter app
App::highlight - a simple grep-like highlighter appAlex Balhatchet
 
Continuous testing and deployment in Perl (London.pm Technical Meeting Octobe...
Continuous testing and deployment in Perl (London.pm Technical Meeting Octobe...Continuous testing and deployment in Perl (London.pm Technical Meeting Octobe...
Continuous testing and deployment in Perl (London.pm Technical Meeting Octobe...Alex Balhatchet
 

More from Alex Balhatchet (8)

Geocoding the World in Perl YAPC::EU 2014
Geocoding the World in Perl YAPC::EU 2014Geocoding the World in Perl YAPC::EU 2014
Geocoding the World in Perl YAPC::EU 2014
 
Test Kit 2.0 YAPC::EU 2014 Lightning Talk
Test Kit 2.0 YAPC::EU 2014 Lightning TalkTest Kit 2.0 YAPC::EU 2014 Lightning Talk
Test Kit 2.0 YAPC::EU 2014 Lightning Talk
 
Nestoria Dev Blog YAPC::EU 2014 Lightning Talk
Nestoria Dev Blog YAPC::EU 2014 Lightning TalkNestoria Dev Blog YAPC::EU 2014 Lightning Talk
Nestoria Dev Blog YAPC::EU 2014 Lightning Talk
 
Test::Kit 2.0 (London.pm Technical Meeting July 2014)
Test::Kit 2.0 (London.pm Technical Meeting July 2014)Test::Kit 2.0 (London.pm Technical Meeting July 2014)
Test::Kit 2.0 (London.pm Technical Meeting July 2014)
 
App::highlight - a simple grep-like highlighter app
App::highlight - a simple grep-like highlighter appApp::highlight - a simple grep-like highlighter app
App::highlight - a simple grep-like highlighter app
 
Continuous testing and deployment in Perl (London.pm Technical Meeting Octobe...
Continuous testing and deployment in Perl (London.pm Technical Meeting Octobe...Continuous testing and deployment in Perl (London.pm Technical Meeting Octobe...
Continuous testing and deployment in Perl (London.pm Technical Meeting Octobe...
 
File::CleanupTask
File::CleanupTaskFile::CleanupTask
File::CleanupTask
 
Authoring CPAN modules
Authoring CPAN modulesAuthoring CPAN modules
Authoring CPAN modules
 

Recently uploaded

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 

Recently uploaded (20)

My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 

Perl 101

  • 1. Perl 101 An introduction to the Perl programming language Alex Balhatchet @ Makers Academy, November 2013
  • 3. Who’s this guy? ● Alex Balhatchet ● CTO at Nestoria property search engine ● Programming Perl for 12 years ● Hiring, training and mentoring Perl interns and permanent hires for 4 years
  • 4. Nestoria ● Property search engine ● Operating in 8 countries, 6 languages ● Serving 1.3 million search requests per day ● 85% Perl, 5% JavaScript, 5% C, 5% Other
  • 7. What is Perl? Perl 5 is a high-level, general purpose, interpreted, dynamic programming language. It was largely inspired by grep, sed, awk, and C. It influenced Python, Ruby, and PHP.
  • 8. So, Perl ● 1.0 released in 1987 ● 5.0 released in 1994 ● Language is now “Perl 5” ● Perl 6 is a new language separate from, but related to, Perl 5
  • 9. So, Perl 5 ● Annual releases since 2010 ● Perl 5.18 was released May 2013 ● Perl 5.20 will be released May 2014 ● New releases contain new features, bug fixes, and performance improvements
  • 11. TIMTOWTDI TIMTOWTDI is pronounced “Tim Toady” and is: There is more than one way to do it Perl aims to be aggressively non-prescriptivist. Every problem should have multiple solutions.
  • 12. Making easy things easy & hard things possible This quote comes from the front of Learning Perl, also known as the Llama. It goes hand-in-hand with TIMTOWTDI. Every problem has multiple solutions implies every problem has at least one solution :-)
  • 13. Do What I Mean Perl’s creator Larry Wall has a linguistics background, and took some of that with him when he designed Perl. Keywords such as “for”, “my”, “defined”, “say”, “do”, “while”, “if”, “unless”, and “use” all read quite nicely to English eyes as well as to programmer eyes.
  • 14. Low Ambiguity In many languages this is acceptable: In Perl we use different operators: puts 1 + 2 puts "a" + "b" say 1 + 2; say "a" . "b"; # 3 # "ab" say "2" + 1; say "2" . 1; # 3 # 21 # 3 # "ab" puts "2" + 1 # !! in `+': can't convert Fixnum into String (TypeError)
  • 16. Variables - Scalars $foo = 1; $bar = 3.14195; $str = "Hello, World!";
  • 17. Variables - Arrays @things = (1, 2, 3); $things[2]; # 3 join(",", @things); # 1,2,3,4
  • 18. Variables - Hashes %hash = ( key => "value", foo => $bar, thingies => "whatsits", ); say $hash{key}; # "value"
  • 19. Variables - Data Structures $alex_hashref = { name => { first => "Alex", last => "Balhatchet", }, languages => [ "English", "German", "Perl" ], };
  • 20. Conditionals if ($true) { say "It’s true!"; } say "It’s true too!" if $true_two;
  • 21. Loops for $i (1 .. 20) { say $i * $i; } while ($line = <STDIN>) { say length $line; }
  • 22. Regular Expressions - Matching $str = "Hello, Makers Academy!"; if ($str =~ m/makers/i) { say "matched!"; } else { say "no match :-("; }
  • 23. Regular Expressions - Matching $num = -1.23456; if ($num =~ m/^ [+-]? d+ ([.]d+)? $/x) { say "looks like a number!"; } else { say "that’s no number I ever saw..."; }
  • 24. Regular Expressions - Substitutions $str = "Hello, Makers Academy!"; $str =~ s/Makers Academy/Makers!/; say $str; # Hello, Makers!!
  • 25. Subroutines sub add { ($num_a, $num_b) = @_; return $num_a + $num_b; } say add(3, 4); # 7 say add(-3, 3); # 0 say add(1/3, 2/3); # 1
  • 26. Objects package MyClass; use MyClass; sub new { $Object = MyClass->new(); ($class) = @_; return bless {}, $class; } sub add { ($self, $n1, $n2) = @_; return $n1 + $n2; } say $Object->add(123, 456);
  • 29. CPAN CPAN stands for Comprehensive Perl Archive Network, and is a collection of Perl modules. You can browse CPAN at cpan.org Today CPAN contains 126,892 Perl modules in 28,607 distributions, written by 11,031 authors, mirrored on 271 servers.
  • 30. CPAN Modules Web Frameworks (Catalyst, Dancer, Mojo) ORMs (DBIx::Class, Fey, Norma) Serialization (XML::Simple, JSON) Maths (Math::Random::MT, Statistics::TTest, Geo::Distance)
  • 32. Unicode Perl was made with text manipulation in mind, and has excellent support for Unicode. All of Perl’s builtin functions, including regular expressions, are Unicode safe. Many CPAN modules that deal with text will also have considered encoding issues.
  • 33. Unicode Examples use utf8::all; $str = "Schwanhäußerstraße"; say $str; # Schwanhäußerstraße say length $str; # 18 $str = uc $str; say $str; # SCHWANHÄUSSERSTRASSE say substr $str, 7, 1; # Ä if ($str =~ m/schwanhäußerstraße/i) { say "I N{HEAVY BLACK HEART} Perl"; } # I ❤ Perl
  • 35. Testing Perl has a big testing culture. Most CPAN modules have a test suite! There are also a good number of CPAN modules to help you with testing your code.
  • 36. Testing Example use Test::More tests => 3; ~$ prove -v example.t example.t .. ok 1, "1 is true"; 1..3 ok 1 - 1 is true is 1 + 1, 2, "1 + 1 = 2"; ok 2 - 1 + 1 = 2 ok 3 - got expected array @a = sort (4, 2, 3, 1); ok is_deeply( All tests successful. @a, [ 1, 2, 3, 4 ], "got expected array" ); Files=1, Tests=3, 0 wallclock secs ( 0.02 usr 0.00 sys + 0.02 cusr 0.00 csys = 0.04 CPU) Result: PASS
  • 38. Perl Community Monthly social meetings (London.pm) Bi-monthly technical meetings (London.pm) Free conference (London Perl Workshop) See the world! YAPC::EU, YAPC::NA, YAPC:: Russia, YAPC::SA, YAPC::Asia, and YAPC:: Australia
  • 41. Perl developers are in demand We are hiring… and so is pretty much every other Perl company! http://lokku.com/jobs http://jobs.perl.org
  • 44. Nestoria Listings Processing ● XML parsing ● Geocoding ● Natural language processing ● De-duplication ● Image thumbnailing
  • 45. The Nestoria Website ● Apache + mod_perl ● Templating with HTML::Mason ● Maketext (and Locale::Maketext) for translations ● Query Analysis / Geographic lookup ● Spell checking and fuzzy matching ● Super fast (90% requests under 200ms)
  • 46. Other Stuff :-) ● geodata system ● Continuous testing and deployment ● Metrics processing system ● Automated PDF and Excel file “end of month” reports ● Email Alerts ● Average House Prices
  • 48. Summary ● Perl has a rich history and an exciting future ● Perl is a straightforward, easy to learn language ● Perl has a lot of advantages (CPAN, Unicode, & Jobs!) ● At Nestoria we’ve shown that Perl can be the foundation of a highly successful and technically sophisticated startup business
  • 51. ht Nes tp to :// ri lo a kk is u. Hi co ri m ng /jo ! bs Thanks! @kaokun @nestoria http://github.com/lokku