Perl

       Kang-min Liu
         @gugod
.meta

• twitter.com/gugod
• Perl / Javascript / Ruby programmer
• CPAN Author for ~100 distributions
• perlbrew
perlbrew
perlbrew

• A tool to install tons of perls
 • switch between them
 • build with customized options
   (-D -A -U)

 • build from tarball or git
Usage

perlbrew install perl-5.12.2
perlbrew install perl-5.13.5




      * Internet connection is required
Usage

perlbrew install perl-5.10.1
perlbrew install perl-5.8.8




      * Internet connection is required
Usage

# git checkout
cd ~/src/perl
perlbrew install .




* Internet connection is not required
Usage

perlbrew installed
> perlbrew installed
perl-5.10.0
perl-5.10.1
perl-5.11.1
perl-5.11.5
perl-5.12.0
perl-5.12.0-RC0
perl-5.12.0-RC3
perl-5.12.1
perl-5.12.2(*)
perl-5.13.0
perl-5.13.2
perl-5.13.4
perl-v5.11.5-15-gd3b0eb1
/Users/gugod/perl5/perlbrew/bin/perl
/Users/gugod/perl5/perlbrew/perls/current/
bin/perl
/usr/bin/perl
Usage

perlbrew switch perl-5.12.2

# Disable perlbrew
perlbrew off
Installation

curl −LO http://xrl.us/perlbrew
chmod +x perlbrew
./perlbrew install
Installation
                                  new




curl -L http://xrl.us/perlbrewinstall | bash
Installation

cpan -i App::perlbrew




    * Not recommended
Properties

• does not require sudo
• perl installation are isolated
 • site_lib, bin, lib
• install a new version ≠ upgrade
 • @INC does not include old site_lib
Benefits

• Easier-to-clean perl environments
 • Nuke the whole thing to clean the
   mess

• Old @INC does not accumulate with
  old perls
Benefits
• per-app isolated perl environments
  setup.

 • avoid, in advance, any possible
   incompatible issues with other
   apps.

 • know your site_libs
• ‘sudo cpan’ is no more.
Why?

• Don’t mess up vendor perl too
  much.

• Learn new stuffs in the dev version
  of perl.

 • keep up with the fashion
Why?

• Test modules or apps
 • ... with newer perl
 • ... with older perl
Why?

• Test perl itself
 • Threaded perl
 • 64bit perl
 • performance
• smokebrew
Why?

• Play dark magic kitchen fire
 • Devel::Declare, B::*, XS
 • Better with a perl built with
    DEBUGING
development

• github.com/gugod/App-perlbrew
• so many pull requests
• 20 contributors
• send me pull requests any time!
development

• better bash integration /
  experiments

• easy site_lib management (clone /
  bundle / nuke)

• Steal some goodies from
  Devel::PPPort
←
← perlbrew

• /usr/local/bin/perl
  /opt/local/bin/perl
  /home/gugod/local/bin/perl

• site_lib is preserved after upgrade
← perlbrew

• perl is so backward compatible
• Ideal for developing and production
• keep upgrading perl is generally OK
← perlbrew

• Upgrading CPAN modules isn’t
  necessarily OK.

• Errors happens at runtime, when it’s
  not binary-compatible.

• Developers must correctly specify
  module dependencies.
← perlbrew


• In CPAN Distribution you do that in
  Makefile.PL / META.yml

• Same tool for App
Simple is Hard

• support for legacy code and
  decisions.

• perl, cpan
• cpanm, perlbrew: new tools for the
  current fashion
Thoughts

perlbrew « cpanm, rvm
Thoughts

• Standalone program
 • embed non-core modules
 • very easy distribution
 • runs a tiny bit faster
Thoughts

• « rvm
 • bash programming master-piece
 • developer-friendly experiences
 • production server
Further Thoughts
• Test::Continuous
• perlbrew
• local::lib
• App::local::lib::helper
• cpanm
• cpan-outdated
• cpansearch
rapidly improves something
a little bit better
rapidly improves something
a little bit better ❤
Hates
Hates
• CPAN dependency list for
  $framework is too long

• CPAN $modules takes too long to
  install / tests takes very long time
  to finish

• $software is too fat (eats too much
  memory space) and slow
Less Hateful

• bundle cpan dists with your
  distribution

• PAR / Shipwright / %INC hack
• Avoid long dependency list
Less Hateful
• smaller, single-purpose
• less memory consumption
• less sub-commands to be
  memorized

 • less memory consumption in your
    brain

• easier to maintain / be faster
cpan install can run 90% faster...
By skiping all tests,
cpan install can run 90% faster...
Less Hateful

• To skip for tests safely, consult
  cpantester.org first

• A cpan/cpanm plugin shall be
  written to automates that.
Less Hateful

• Solving long dependency list
  problem is a no-op

 • if cpan installation is super fast
 • like < 1 second / module
Fast fists cannot be broken
side projects
cpan-sets

• cpan-sets: local::lib switcher wrote in
 • « rvm gemset, bundler
 • App::local::lib::helper
 • experimental project
• per-app bundle
cpanfile
# Install with: cpanm < cpanfile
http://github.com/bestpractical/jifty-dbi/tarball/master
http://github.com/bestpractical/jifty/tarball/master
http://github.com/bestpractical/jifty-plugin-openid
B::Hooks::EndOfScope
DateTime
Digest::SHA1
Email::Address
Exporter::Lite
HTML::Entities
JiftyX::Markapl
JiftyX::ModelHelpers
Markapl
Regexp::Common
Regexp::Common::Email::Address
String::BufferStack
Sub::Install
Text::Markdown::Discount
Text::MultiMarkdown
UNIVERSAL::require
common::sense
perlrocks
• rubygems counter-part.
• multi-version module     install

• use perlrocks;
  # perl5 syntax of ‘use’
  use Foo-1.3;

• site_lib/rocks/Foo-1.3/lib/Foo.pm
• Installation tool (rock)
side projects

• github.com/gugod/App-perlbrew
• github.com/gugod/cpan-sets
• github.com/gugod/perlrocks
Conclusion

• github social coding actually works!
• Easy distributing is important.
• Simple is hard.
• Fast is better then slow.
∞

• Good + Simple + Easy toolkit
• Keep new-comers by not frustrating
  them

• Grow the community
Thank You

perlbrew yapcasia 2010