4. I'mma talk pretty fast. Feel free to ask
questions particularly if I'm moving
too quickly!
just to give me a benchmark, how
many folks here identify as perl
coders? how many folks are happy
about that?
disclaimer
5. I was inspired to write this talk by a few online
friends who happen to be Perl programmers — but
they're not engaged with the community, they're
just using Perl to get a job done, and there's a
widening gulf between what I think is reasonable
and what they're doing — so I wanted to put
together sort of an info dump to bring people up to
speed. this talk is going to be a wide-ranging
survey of what's happened in Perl in the last couple
decades, give or take.
i‘m just a caveman
your “modern perl”
frightens and confuses me
6. as you may have heard
perl6
was released!6 — old dogs & new tricks — ato 2019 — @genehack
7. as you also may have heard
but this talk is about perl5, so that's
the last i'm going to talk about raku
nee perl6
if you want to talk more about that,
find me at a social event or in the
bar...
perl6
was just renamed to
raku!7 — old dogs & new tricks — ato 2019 — @genehack
11. here's the release dates for
several perl versions, starting
with 5.6 (latest and greatest in
2001, remember) mention
even-odd numbering
convention
5.6.0 - 22 Mar 2000
5.8.0 - 18 Jul 2002
5.10.0 - 18 Dec 2007
5.12.0 - 12 April 2010
11 — old dogs & new tricks — ato 2019 — @genehack
12. see that five year gap there?
yeah, those were not great
times
5.6.0 - 22 Mar 2000
5.8.0 - 18 Jul 2002
5.10.0 - 18 Dec 2007
5.12.0 - 12 April 2010
12 — old dogs & new tricks — ato 2019 — @genehack
13. but, starting with 5.10, which
sort of brought perl 5 back to
life, and then particularly, since
5.12, we've had this great
thing! ...
5.6.0 - 22 Mar 2000
5.8.0 - 18 Jul 2002
5.10.0 - 18 Dec 2007
5.12.0 - 12 April 2010
13 — old dogs & new tricks — ato 2019 — @genehack
14. a regular, predictable release
cycle!
regular
release cycle
14 — old dogs & new tricks — ato 2019 — @genehack
15. here are all the releases since
5.12. notice anything?
5.12.0 - 12 April 2010
5.14.0 - 14 May 2011
5.16.0 - 20 May 2012
5.18.0 - 18 May 2013
5.20.0 - 27 May 2014
5.22.0 - 01 Jun 2015
5.24.0 - 09 May 2016
5.26.0 - 30 May 2017
5.28.0 - 20 May 2018
5.30.0 - 22 May 2019
15 — old dogs & new tricks — ato 2019 — @genehack
16. 5.12.0 - 12 April 2010
5.14.0 - 14 May 2011
5.16.0 - 20 May 2012
5.18.0 - 18 May 2013
5.20.0 - 27 May 2014
5.22.0 - 01 Jun 2015
5.24.0 - 09 May 2016
5.26.0 - 30 May 2017
5.28.0 - 20 May 2018
5.30.0 - 22 May 2019
16 — old dogs & new tricks — ato 2019 — @genehack
17. credit for starting and more
importantly continuing this goes to
a couple of p5 pumpkings, which is
what we call the person who is in
charge of the Perl5 effort — our
Benevolent Dictator for the
Moment, if you will
perl5
pumpking17 — old dogs & new tricks — ato 2019 — @genehack
18. jesse vincent
5.12.0 - 12 April 2010
5.14.0 - 14 May 2011
5.16.0 - 20 May 2012
5.18.0 - 18 May 2013
5.20.0 - 27 May 2014
5.22.0 - 01 Jun 2015
5.24.0 - 09 May 2016
5.26.0 - 30 May 2017
5.28.0 - 20 May 2018
5.30.0 - 22 May 2019
18 — old dogs & new tricks — ato 2019 — @genehack
19. rik signes
5.12.0 - 12 April 2010
5.14.0 - 14 May 2011
5.16.0 - 20 May 2012
5.18.0 - 18 May 2013
5.20.0 - 27 May 2014
5.22.0 - 01 Jun 2015
5.24.0 - 09 May 2016
5.26.0 - 30 May 2017
5.28.0 - 20 May 2018
5.30.0 - 22 May 2019
19 — old dogs & new tricks — ato 2019 — @genehack
20. sawyer x
5.12.0 - 12 April 2010
5.14.0 - 14 May 2011
5.16.0 - 20 May 2012
5.18.0 - 18 May 2013
5.20.0 - 27 May 2014
5.22.0 - 01 Jun 2015
5.24.0 - 09 May 2016
5.26.0 - 30 May 2017
5.28.0 - 20 May 2018
5.30.0 - 22 May 2019
20 — old dogs & new tricks — ato 2019 — @genehack
21. getting back onto a regular
predictable release cycle has
arguably been the single greatest
factor keeping Perl5 relevant and
catalyzing the Perl "Renaissance"
you may be hearing about
regular
release cycle
21 — old dogs & new tricks — ato 2019 — @genehack
22. much respect to Jesse, Rik,
and Sawyer for the work
involved in this, it was not a
trivial undertaking to start or to
keep going.
❤ jesse
❤ rik
❤ sawyer
22 — old dogs & new tricks — ato 2019 — @genehack
23. Another catalyst for the Perl
Renaissance is the book "Modern
Perl", written by chromatic. He
has made this freely available
online; you can also purchase a
paper copy if that's how you roll.
modern perl
modernperlbooks.com
23 — old dogs & new tricks — ato 2019 — @genehack
24. Writing this book was a
tremendous effort and it's an
absolutely essential read if you
want to understand what we
call "Modern Perl", or how we
do Perl in the 21st century.
❤ chromatic
modernperlbooks.com
24 — old dogs & new tricks — ato 2019 — @genehack
25. One of the main benefits of the
regular release cycle has been a
number of language improvements.
I'm only going to talk about a few
today, but you can always read the
'perldeltas', or change summaries
that come out with each new release.
many
language improvements
25 — old dogs & new tricks — ato 2019 — @genehack
26. In 2001, the world of Perl 5.6, Unicode
existed but wasn't very well understood or
very widely used. Today, of course, we live
in a Unicode world, and it's something all
programmers and languages have to deal
with. It's kinda too complicated to get into
here, so I'm just going to say that now we
can get really expressive in our Perl code
unicode
support!26 — old dogs & new tricks — ato 2019 — @genehack
27. So it's much easier to tell if
we're happy...
$code = " ";
27 — old dogs & new tricks — ato 2019 — @genehack
28. ... or when things aren't going
quite as well.
$code = " ";
28 — old dogs & new tricks — ato 2019 — @genehack
30. Before I can explain this next one, I need to do
a brief refresher on a couple of aspects of Perl.
Perl has the usual notion of true/false. These
four values are false; everything else is true.
'undef' is a special value; it's what Perl gives
to a newly declared but uninitialized variable.
That means there's this additional dimension
of defined/undefined we have to deal with
false values:
0, '', ( ), undef
everything else is true
30 — old dogs & new tricks — ato 2019 — @genehack
31. Before I can explain this next one, I need to do
a brief refresher on a couple of aspects of Perl.
Perl has the usual notion of true/false. These
four values are false; everything else is true.
'undef' is a special value; it's what Perl gives
to a newly declared but uninitialized variable.
That means there's this additional dimension
of defined/undefined we have to deal with
undefined values:
undef
everything else is defined
31 — old dogs & new tricks — ato 2019 — @genehack
32. boolean operators
(or, ||, and, &&)
look at truthiness.32 — old dogs & new tricks — ato 2019 — @genehack
33. So can't look at truthiness;
must look at definedness
but, many times,
the only invalid value
for something is
undef33 — old dogs & new tricks — ato 2019 — @genehack
34. if ( defined( $this )) {
$value = $this;
}
else {
$value = 'default';
}
34 — old dogs & new tricks — ato 2019 — @genehack
35. The more idiomatic way of
writing that code is to use the
ternary operator — this just
does the same thing as the
previous slide in a more
compact way
$value = defined($this)
? $this
: 'default';
35 — old dogs & new tricks — ato 2019 — @genehack
36. Now that I've given you that
background, now I can explain this
great new feature we got in 5.10,
called 'defined-or'. It let's you write
that code like so. Which is pretty
awesome. Defined-or was my
favorite new perl feature of the 2000s
defined-or
$value = $this // 'default'
36 — old dogs & new tricks — ato 2019 — @genehack
37. You can also combine this with
the assignment operator, in
much the same way you can
say ||= for 'or equals'
defined-or
$this //= 'default'
# kinda like this…
$this ||= 'default'
37 — old dogs & new tricks — ato 2019 — @genehack
39. Regular expressions are a big part of
Perl programming, including
substitution style regexps. If you want
to apply a substitution to a variable but
not change your original value, you
need to do something like this - make
a copy, then do the sub on the copy
regexp refinements
my $copy = $orig;
$copy =~ s/swap/stuff/;
39 — old dogs & new tricks — ato 2019 — @genehack
40. and this is just a more idiomatic way to do
the same thing.
this makes the copy (and the parens are
required)...
and then this applies the sub to the result
of the left hand side, which means $copy
gets changed and $orig is left unchanged
regexp refinements
(my $copy = $orig) =~ s/swap/stuff/;
40 — old dogs & new tricks — ato 2019 — @genehack
41. new in 5.14, we have a new way do this.
don't need the parens. the key here this ...
is 'r' modifier to the regexp, which makes
this part return the result of applying the
sub to $orig (hence, 'r' - for return)
and then we just assign that to $copy.
Again, new as of 5.14.0
regexp refinements
my $copy = $orig =~ s/swap/stuff/r;
41 — old dogs & new tricks — ato 2019 — @genehack
42. Finally, and I think this is
maybe the biggest feature this
decade, we've also recently
gotten support for subroutine
signatures in 5.20
subroutine
signatures
42 — old dogs & new tricks — ato 2019 — @genehack
43. this is how you might write a simple perl
function to add together two numbers.
the @_ is a special variable that's used to
pass in the arguments for the function.
This bit in the first line is called
"unpacking @_", and code like this is at
the top of literally almost every Perl
function EVER
sub add {
my ($one, $two) = @_;
return $one + $two;
}
43 — old dogs & new tricks — ato 2019 — @genehack
44. this code does the exact same thing!
so we don't even have to unpack @_
ourselves! you can even provide default
values, validate arguments in the function
signature, and all sorts of crazy stuff
Who has started using subroutine signatures?
They're still experimental, but hopefully will be
non-experimental in a future release
sub add ($one, $two) {
return $one + $two;
}
44 — old dogs & new tricks — ato 2019 — @genehack
45. In addition to adding new
language features, some
earlier mistakes have been
corrected
some improvements
are actually
removals
45 — old dogs & new tricks — ato 2019 — @genehack
46. (as of Perl 5.30)
anybody know what this
special variable does?
Assigning non-zero values
to $[ is
fatal!46 — old dogs & new tricks — ato 2019 — @genehack
47. It's not just language level
features, we also have a host
of new tools to make it easier
to work with Perl
new tools
48. These days, we make a
distinction between the Perl
that comes with your OS
“system” perl
48 — old dogs & new tricks — ato 2019 — @genehack
49. and encourage people not to
use it for their development
projects
“system” perl:
just say no
49 — old dogs & new tricks — ato 2019 — @genehack
50. Yes, that means good old /usr/
bin/perl...
/usr/bin/perl
50 — old dogs & new tricks — ato 2019 — @genehack
51. is no more. Instead, we use
tools to install new Perls,
outside the control of the OS
/usr/bin/perl
52. The first tool that was
developed for this purpose is
called Perlbrew
perlbrew
52 — old dogs & new tricks — ato 2019 — @genehack
58. either one of these tools will
give you numerous
advantages over using the
system perl
advantages
• solves “vendor perl lockin” issues
• install multiple perls in your home directory
• … or elsewhere
• trivially switch from perl version to perl version
• able to install modules without special
permissions
• easy to stay up to date with perl development
58 — old dogs & new tricks — ato 2019 — @genehack
59. personally, i'm using plenv
these days — the ability to
easily specify a Perl version for
a particular project is
particularly useful to me
plenv > perlbrew
• less magic messing around with $path
• can “pin” perl different ways: globally, per-shell, or
per-directory
59 — old dogs & new tricks — ato 2019 — @genehack
60. perlbrew > plenv
• kicka** website
60 — old dogs & new tricks — ato 2019 — @genehack
61. we also have a few new tools
that make installing and
managing modules easier
speaking of
installing…
61 — old dogs & new tricks — ato 2019 — @genehack
62. one of them is a module called
local::lib
local::lib
62 — old dogs & new tricks — ato 2019 — @genehack
63. local::lib
• install your own copies of modules
• in your $HOME (so no special permissions needed)
• can also install per-project modules
• integrates well with other tools
• not going to go into how to make it work, but the
docs are great!
63 — old dogs & new tricks — ato 2019 — @genehack
64. originally developed by matt
trout, so thanks matt
❤ mst
64 — old dogs & new tricks — ato 2019 — @genehack
66. We've got a new CPAN client
these days, cpanminus
cpanminus
a/k/a
cpanm66 — old dogs & new tricks — ato 2019 — @genehack
67. this is the output from using
the default 'cpan' client to
install something.
% cpan Git::Wrapper
CPAN: Storable loaded ok (v2.54)
Reading '/Users/genehack/.cpan/Metadata'
Database was generated on Sat, 10 Oct 2015 01:17:02 GMT
Running install for module 'Git::Wrapper'
CPAN: LWP::UserAgent loaded ok (v6.13)
Fetching with LWP:
http://cpan.schatt.com/authors/id/G/GE/GENEHACK/Git-Wrapper-0.045.tar.gz
CPAN: YAML loaded ok (v1.15)
CPAN: Digest::SHA loaded ok (v5.95)
Fetching with LWP:
http://cpan.schatt.com/authors/id/G/GE/GENEHACK/CHECKSUMS
CPAN: Compress::Zlib loaded ok (v2.068)
Checksum for /Users/genehack/.cpan/sources/authors/id/G/GE/GENEHACK/Git-Wrapper-0.045.tar.gz ok
tmp-47326 for tmp-47326: No such file or directory at /opt/plenv/versions/5.23.2/lib/perl5/5.23.2/CPAN/Distribution
.pm line 468.
CPAN: File::Temp loaded ok (v0.2304)
CPAN: CPAN::Meta::Requirements loaded ok (v2.133)
CPAN: Parse::CPAN::Meta loaded ok (v1.4417)
CPAN: CPAN::Meta loaded ok (v2.150005)
CPAN: Module::CoreList loaded ok (v5.20150820)
Configuring G/GE/GENEHACK/Git-Wrapper-0.045.tar.gz with Makefile.PL
Locating bin:git... found at /opt/git/bin/git.
Checking if your kit is complete...
Looks good
Generating a Unix-style Makefile
Writing Makefile for Git::Wrapper
Writing MYMETA.yml and MYMETA.json
67 — old dogs & new tricks — ato 2019 — @genehack
68. and this is more of the output...
GENEHACK/Git-Wrapper-0.045.tar.gz [17/1516]
/opt/plenv/versions/5.23.2/bin/perl5.23.2 Makefile.PL -- OK
Running make for G/GE/GENEHACK/Git-Wrapper-0.045.tar.gz
cp lib/Git/Wrapper/File/RawModification.pm blib/lib/Git/Wrapper/File/RawModification.pm
cp lib/Git/Wrapper.pm blib/lib/Git/Wrapper.pm
cp lib/Git/Wrapper/Statuses.pm blib/lib/Git/Wrapper/Statuses.pm
cp lib/Git/Wrapper/Exception.pm blib/lib/Git/Wrapper/Exception.pm
cp lib/Git/Wrapper/Log.pm blib/lib/Git/Wrapper/Log.pm
cp lib/Git/Wrapper/Status.pm blib/lib/Git/Wrapper/Status.pm
Manifying 6 pod documents
GENEHACK/Git-Wrapper-0.045.tar.gz
/usr/bin/make -- OK
Running make test
PERL_DL_NONLAZY=1 "/opt/plenv/versions/5.23.2/bin/perl5.23.2" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "und
ef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/00-load.t ............... 1/6 # Testing Git::Wrapper 0.045
t/00-load.t ............... ok
t/author-err.t ............ skipped: these tests are for testing by the author
t/basic.t ................. # Testing git version: 2.5.2
t/basic.t ................. ok
t/git_binary.t ............ ok
t/parse_args.t ............ ok
t/path_class.t ............ # Testing git version: 2.5.2
t/path_class.t ............ ok
t/release-pod-coverage.t .. skipped: these tests are for release candidate testing
t/release-pod-syntax.t .... skipped: these tests are for release candidate testing
All tests successful.
Files=8, Tests=67, 1 wallclock secs ( 0.04 usr 0.02 sys + 0.39 cusr 0.31 csys = 0.76 CPU)
Result: PASS
GENEHACK/Git-Wrapper-0.045.tar.gz
68 — old dogs & new tricks — ato 2019 — @genehack
69. (still not done
but I got tired of
pasting.)69 — old dogs & new tricks — ato 2019 — @genehack
70. this is the output from cpanm
installing the same thing
% cpanm Git::Wrapper
--> Working on Git::Wrapper
Fetching http://www.cpan.org/authors/id/G/GE/GENEHACK/Git-Wrapper-0.045.tar.gz ... OK
Configuring Git-Wrapper-0.045 ... OK
Building and testing Git-Wrapper-0.045 ... OK
Successfully installed Git-Wrapper-0.045
70 — old dogs & new tricks — ato 2019 — @genehack
72. Another tool, carton, helps
manage your module
dependencies in a project.
Particularly useful for large
projects with multiple devs
carton
72 — old dogs & new tricks — ato 2019 — @genehack
73. it's like ruby's bundler or
package-lock.json for npm,
but for perl modules.
bundler
but for perl
73 — old dogs & new tricks — ato 2019 — @genehack
74. freeze deps,
so you always install same versions across
dev/staging/prod
74 — old dogs & new tricks — ato 2019 — @genehack
75. both cpanm and carton were
developed by Miyagawa;
many thanks to him!
❤ miyagawa
75 — old dogs & new tricks — ato 2019 — @genehack
76. Another tool, pinto, let's you have your
own private CPAN within your
organization. Great if you have a number
of devs working on things
independently, because folks can do
releases, make modules available,
without having to build system packages
pinto76 — old dogs & new tricks — ato 2019 — @genehack
77. Another tool, pinto, let's you have your
own private CPAN within your
organization. Great if you have a number
of devs working on things
independently, because folks can do
releases, make modules available,
without having to build system packages
your very own
private CPAN
77 — old dogs & new tricks — ato 2019 — @genehack
78. pinto was developed by Jeff
Thalhammer
❤ jeff thalhammer
78 — old dogs & new tricks — ato 2019 — @genehack
89. anybody doing web development
these days needs to interact with
JSON - using JSON::MaybeXS will
make sure that you have a JSON
library available, picking the best
one from a number of alternatives
JSON::MaybeXS
89 — old dogs & new tricks — ato 2019 — @genehack
90. here's how the fallback works —
and if you install JSON::MaybeXS
and don't have any of these
installed, it will require
Cpanel::JSON::XS (as long as you
have a compiler to build the XS)
Cpanel::JSON::XS
JSON::XS
JSON::PP90 — old dogs & new tricks — ato 2019 — @genehack
91. To get a handle on how we do
OOP in Perl these days, you should
look into Moose — and then when
you're ready to write some code,
you'll probably be able to get away
with dropping down to Moo
Moose
Moo91 — old dogs & new tricks — ato 2019 — @genehack
92. I do have some bad news for
you — CGI.pm has been
pulled out of core
CGI.pm
is
gone92 — old dogs & new tricks — ato 2019 — @genehack
93. don't worry, you can still find it
on CPAN
(not really)
93 — old dogs & new tricks — ato 2019 — @genehack
94. But the current standard for
web development in Perl is
Plack/PSGI. Offers a number
of advantages over CGI, and is
the basis for all modern Perl
web frameworks
plack94 — old dogs & new tricks — ato 2019 — @genehack
103. % cpanm Git::Wrapper
--> Working on Git::Wrapper
Fetching http://www.cpan.org/authors/id/G/GE/GENEHACK/Git-Wrapper-0.045.tar.gz ... OK
Configuring Git-Wrapper-0.045 ... OK
Building and testing Git-Wrapper-0.045 ... OK
Successfully installed Git-Wrapper-0.045
103 — old dogs & new tricks — ato 2019 — @genehack
108. finally, you really should
consider becoming more
actively involved with the perl
community, if you're working
with (or even just playing with)
perl
speaking of Perl
community…
108 — old dogs & new tricks — ato 2019 — @genehack
109.
110. big conferences: TPC, once a year (or
so), in North America, Europe, Asia.
Sometimes Brazil, Russia too
workshops: smaller, regional.
Pittsburgh, DC-Baltimore, Orlando
perl mongers groups: like MasterCard,
we errywhere you want to be
conferences & workshops
& mongers
(oh my.)
111. you really should consider
becoming more actively involved
with the perl community, if you're
working with (or even just playing
with) perl, there's probably a local
perl mongers group near you
112. you really should consider
becoming more actively involved
with the perl community, if you're
working with (or even just playing
with) perl, there's probably a local
perl mongers group near you
www.pm.org/groups/north_america.html
113. finally, let me give a big shout
out to perl weekly, which is a
once a week email newsletter
and website aggregating perl
related news from all over the
web
114. finally, let me give a big shout out to perl
weekly, which is a once a week email
newsletter and website aggregating
perl related news from all over the web
if you're only going to pay attention to
one perl thing, perl weekly is your best
choice! sign up at perlweekly.com
perlweekly.com
115. if you have time this is the place to do a little riff about how it's
important to pay attention to Perl because as one of the the
oldest open source language communities, we're further thru
our lifecycle than other communities. the things that have
happened in perl -- succession, maintainers dying, language
getting stagnant and unstuck, etc -- are the types of things
you can expect to see in other open source language
communities in the future. seeing how perl has successfully --
or unsuccessfully -- dealt with these challengers can provide a
model for other communities
maybe also riff on how perl:IT::excel:business and how even if
you don't think it's being used, it's probably being used
thanks
115 — old dogs & new tricks — ato 2019 — @genehack