Modern Perl for the Unfrozen Paleolithic Perl Programmer
-
Upload
john-anderson -
Category
Internet
-
view
821 -
download
3
Transcript of Modern Perl for the Unfrozen Paleolithic Perl Programmer
Modern Perl for the Unfrozen Paleolithic
Perl ProgrammerJohn SJ Anderson ⭐ Infinity Interactive ⭐ @genehack
DC-Balmer Perl Workshop ⭐ 16 Apr 2016
Disclaimer
I'mma talk pretty fast. Feel free to ask questions particularly if I'm moving too quickly
I'M JUST A CAVEMAN
YOUR MODERN PERL FRIGHTENS AND CONFUSES ME
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 and what they're doing -- so I wanted to put together sort of an info dump
Quite a few things have changed...
Many things have changed since you fell into that glacier in 2001,
Unicode support!
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
defined($this)?$this:$that
defined-or
We got a great new feature in 5.10 called defined-or.
You've probably written code much like this hundreds of times.
$this//$that
defined-or
Now, we can just write this!
Which is pretty awesome. Defined-or was my favorite new perl feature of the 2000s
subadd($one,$two){return$one+$two;}
so we don't even have to unpack @_ ourselves!
Who has started using subroutine signatures?
new toolsIt's not just language level features, we also have a host of new tools to make it easier to work with 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
either one of these tools will give you numerous advantages over using the system perl
plenv > perlbrew• Less magic messing around with PATH
• Can "pin" Perl different ways: globally, per-shell, or per-directory
personally, i'm using plenv these days -- the ability to easily specify a Perl version for a particular project is particularly useful to me
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
%cpanGit::WrapperCPAN:Storableloadedok(v2.54)Reading'/Users/genehack/.cpan/Metadata'DatabasewasgeneratedonSat,10Oct201501:17:02GMTRunninginstallformodule'Git::Wrapper'CPAN:LWP::UserAgentloadedok(v6.13)FetchingwithLWP:http://cpan.schatt.com/authors/id/G/GE/GENEHACK/Git-Wrapper-0.045.tar.gzCPAN:YAMLloadedok(v1.15)CPAN:Digest::SHAloadedok(v5.95)FetchingwithLWP:http://cpan.schatt.com/authors/id/G/GE/GENEHACK/CHECKSUMSCPAN:Compress::Zlibloadedok(v2.068)Checksumfor/Users/genehack/.cpan/sources/authors/id/G/GE/GENEHACK/Git-Wrapper-0.045.tar.gzoktmp-47326fortmp-47326:Nosuchfileordirectoryat/opt/plenv/versions/5.23.2/lib/perl5/5.23.2/CPAN/Distribution.pmline468.CPAN:File::Temploadedok(v0.2304)CPAN:CPAN::Meta::Requirementsloadedok(v2.133)CPAN:Parse::CPAN::Metaloadedok(v1.4417)CPAN:CPAN::Metaloadedok(v2.150005)CPAN:Module::CoreListloadedok(v5.20150820)ConfiguringG/GE/GENEHACK/Git-Wrapper-0.045.tar.gzwithMakefile.PLLocatingbin:git...foundat/opt/git/bin/git.Checkingifyourkitiscomplete...LooksgoodGeneratingaUnix-styleMakefileWritingMakefileforGit::WrapperWritingMYMETA.ymlandMYMETA.json
this is the output from using the default 'cpan' client to install something.
GENEHACK/Git-Wrapper-0.045.tar.gz[17/1516]/opt/plenv/versions/5.23.2/bin/perl5.23.2Makefile.PL--OKRunningmakeforG/GE/GENEHACK/Git-Wrapper-0.045.tar.gzcplib/Git/Wrapper/File/RawModification.pmblib/lib/Git/Wrapper/File/RawModification.pmcplib/Git/Wrapper.pmblib/lib/Git/Wrapper.pmcplib/Git/Wrapper/Statuses.pmblib/lib/Git/Wrapper/Statuses.pmcplib/Git/Wrapper/Exception.pmblib/lib/Git/Wrapper/Exception.pmcplib/Git/Wrapper/Log.pmblib/lib/Git/Wrapper/Log.pmcplib/Git/Wrapper/Status.pmblib/lib/Git/Wrapper/Status.pmManifying6poddocumentsGENEHACK/Git-Wrapper-0.045.tar.gz/usr/bin/make--OKRunningmaketestPERL_DL_NONLAZY=1"/opt/plenv/versions/5.23.2/bin/perl5.23.2""-MExtUtils::Command::MM""-MTest::Harness""-e""undef*Test::Harness::Switches;test_harness(0,'blib/lib','blib/arch')"t/*.tt/00-load.t...............1/6#TestingGit::Wrapper0.045t/00-load.t...............okt/author-err.t............skipped:thesetestsarefortestingbytheauthort/basic.t.................#Testinggitversion:2.5.2t/basic.t.................okt/git_binary.t............okt/parse_args.t............okt/path_class.t............#Testinggitversion:2.5.2t/path_class.t............okt/release-pod-coverage.t..skipped:thesetestsareforreleasecandidatetestingt/release-pod-syntax.t....skipped:thesetestsareforreleasecandidatetestingAlltestssuccessful.Files=8,Tests=67,1wallclocksecs(0.04usr0.02sys+0.39cusr0.31csys=0.76CPU)Result:PASSGENEHACK/Git-Wrapper-0.045.tar.gz
and this is more of the output...
%cpanmGit::Wrapper-->WorkingonGit::WrapperFetchinghttp://www.cpan.org/authors/id/G/GE/GENEHACK/Git-Wrapper-0.045.tar.gz...OKConfiguringGit-Wrapper-0.045...OKBuildingandtestingGit-Wrapper-0.045...OKSuccessfullyinstalledGit-Wrapper-0.045
this is the output from cpanm installing the same thing
https://metacpan.org/but metacpan integrates and visualizes a bunch of information in a really useful way
https://metacpan.org/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
https://github.com/CPAN-API/metacpan-web
it's also open source, so if you can think of a way to make it better, you can
Duck Duck Go
we also have a new search engine here in 2016. it's cool, and it's partially written in Perl
Duck Duck Go !cpanm
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
speaking of modules...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
JSON::MaybeXS
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
MooseMoo
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
PlackBut 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
speaking of Perl websites…
we have quite a few new websites these days, which make it easier to keep up with the current state of things
http://cpanratings.perl.org/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
http://cpanratings.perl.org/you can see individual reviews, which version they're reviewing, and so on.
http://cpants.cpanauthors.org/
we also have CPANTS - automated testing of some best practices around module development
http://cpants.cpanauthors.org/
here's what that looks like for a particular module. super useful if you're not sure you're doing things the "right" way
http://prepan.org/We also have PrePAN, which is a place to get feedback on module ideas you haven't even written yet
speaking of staying up to date on Perl news…
we also have some sites that make it easier to keep up to date with what's going on in the perl world
http://perlweekly.com/there's perl weekly, which is a once a week email newsletter aggregating perl related news from all over the web
http://blogs.perl.org/users/sawyer_x/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