Modern Perl for the
Unfrozen Paleolithic
Perl Programmer
John SJ Anderson ⭐︎ Infinity Interactive ⭐︎ @genehack
Pittsburgh Perl Workshop 2015 ⭐︎ 11 Oct 2015
I'M JUST A CAVEMAN
DERN PERL FRIGHTENS AND CON
Quite a few
things have
changed...
...but many
haven't
You're just in time
for the Perl6
release party
We're still
using Perl5!
Many
language
improvements
defined($this) ? $this : $that
defined-or
$this // $that
defined-or
subroutine
signatures
sub add ($one, $two) {
return $one + $two;
}
new tools
"system" perl:
"system" perl:
just say no
/usr/bin/perl
/usr/bin/perl
perlbrew.pl
https://github.com/tokuhirom/plenv
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
plenv > perlbrew
• Less magic messing around with PATH
• Can "pin" Perl different ways: globally, per-shell, or
per-directory
perlbrew > plenv
• Kickass website
ing of installing in your $H
local::lib
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
speaking of installing stuff…
cpanminus
cpanm
% 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
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
(still not done
but I got tired
of pasting.)
% 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
speaking of stuff on CPAN…
https://metacpan.org/
search.cpan.org
https://metacpan.org/
https://metacpan.org/
https://github.com/CPAN-API/metacpan-web
Duck Duck Go
Duck Duck Go
speaking of modules...
JSON::MaybeXS
CGI.pm
is
gone
(not really)
speaking of Perl websites…
http://cpanratings.perl.org/
http://cpanratings.perl.org/
https://metacpan.org/
http://cpants.cpanauthors.org/
http://cpants.cpanauthors.org/
https://metacpan.org/
http://prepan.org/
g of staying up to date on Perl
http://perlweekly.com/
http://blogs.perl.org/users/sawyer_x/
speaking of
retrospectives…
questions?

Modern Perl for the Unfrozen Paleolithic Perl Programmer

Editor's Notes

  • #3 I was inspired to give 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 -- so I wanted to put together sort of an info dump
  • #4 So, hi, unfrozen caveman Perl programmer! Welcome to 2015!
  • #5 Many things have changed since you fell into that glacier in 2001,
  • #7 Perl6 is still just about going to be released!
  • #8 Most of us are still happily coding in Perl5, however
  • #9 When you slipped into that big hole in the ice, perl 5.6 was the latest and greatest
  • #10 But we're all the way up to 5.22 now
  • #12 You probably don't remember Unicode -- it was around in 2001, but not terribly important or very well understood. It's way too complicated to get into here, just know that now we can get _really_ expressive in our Perl code
  • #13 So it's much easier to tell if we're happy...
  • #14 ... or when things aren't going quite as well.
  • #15 This should be a familiar way of communication for you!
  • #16 We got a great new feature in 5.10 called defined-or. You've probably written code much like this hundreds of times.
  • #17 Now, we can just write this! Which is pretty awesome. Defined-or was my favorite new perl feature of the 2000s
  • #18 Finally, we've also recently gotten support for subroutine signatures
  • #19 so we don't even have to unpack @_ ourselves! Who has started using subroutine signatures?
  • #20 It's not just language level features, we also have a host of new tools to make it easier to work with Perl
  • #21 These days, we make a distinction between the Perl that comes with your OS
  • #22 and encourage people not to use it for their development projects
  • #23 Yes, that means good old /usr/bin/perl...
  • #24 is no more. Instead, we use tools to install new Perls, outside the control of the OS
  • #25 The first tool that was developed for this purpose is called Perlbrew
  • #26 which you can get at perlbrew.pl
  • #27 there's also a newer option, plenv
  • #28 it's website isn't quite as snazzy as perlbrew's
  • #29 either one of these tools will give you numerous advantages over using the system perl
  • #30 personally, i'm using plenv these days -- the ability to easily specify a Perl version for a particular project is particularly useful to me
  • #36 We've got a new CPAN client these days
  • #37 this is the output from using the default 'cpan' client to install something.
  • #38 and this is more of the output...
  • #40 this is the output from cpanm installing the same thing
  • #42 we have a whole new website for interacting with CPAN
  • #43 search.cpan.org is still around...
  • #44 but metacpan integrates and visualizes a bunch of information in a really useful way
  • #45 things like a syntax-highlighted source view, linking to home pages and code repos, showing test results, and the amount of activity in a project
  • #46 it's also open source, so if you can think of a way to make it better, you can
  • #47 we also have a new search engine here in 2015. it's cool, and it's partially written in Perl
  • #48 The most useful feature, though, is ability to use 'bang searches' to restrict your search to a particular site - this is how you search metacpan
  • #49 if you haven't been playing close attention (and since you were frozen, you haven't been!) there are a few new modules you may have missed
  • #50 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
  • #51 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
  • #52 I do have some bad news for you -- CGI.pm has been pulled out of core
  • #53 don't worry, you can still find it on CPAN
  • #54 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
  • #55 we have quite a few new websites these days, which make it easier to keep up with the current state of things
  • #56 one of the problems with cpan is there's just _so_ _much_ _stuff_ there. it can be hard to decide which one of a dozen different modules to use. cpanratings helps with this problem
  • #57 you can see individual reviews, which version they're reviewing, and so on.
  • #58 MetaCPAN links to reviews as well as showing an average review score
  • #59 we also have CPANTS - automated testing of some best practices around module development
  • #60 here's what that looks like for a particular module. super useful if you're not sure you're doing things the "right" way
  • #61 MetaCPAN links to CPANTS too
  • #62 We also have PrePAN, which is a place to get feedback on module ideas you haven't even written yet
  • #63 we also have some sites that make it easier to keep up to date with what's going on in the perl world
  • #64 there's perl weekly, which is a once a week email newsletter aggregating perl related news from all over the web
  • #65 and in a recent development, sawyer has revived the p5p weekly email summary -- excellent if you want to keep up with what's going on with perl5 development but don't have time to follow the email list yourself
  • #66 Before I get wrap up and take questions, I want to thank Dan for accepting my talk -- I gave my first ever Perl talk at a PPW and it's always great to come back to Pittsburgh and see a bunch of familiar faces