Perl is a high-level, general purpose programming language that was introduced in 1987 and remains widely used today. It draws inspiration from languages like C, sed, awk, and grep. The document provides an introduction to Perl's history and basics, including variables, conditionals, loops, regular expressions, subroutines and objects. It highlights advantages like the comprehensive CPAN module library, strong Unicode support, testing culture, and job opportunities. The author works at Nestoria, where Perl powers their property search engine, handling tasks like XML parsing, geocoding, and image processing.
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)
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...";
}
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.
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
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