Perl_and_Catalyst.Josh_Poritz
Document Sample


Perl and Catalyst: The Chemistry
Just Couldn’t be Any Better.
Josh Poritz
Why do people complain about perl?
$;=pop;{$.= perl -e'map\
0;map{$;%$_ {map{print chr }/\d\
or$.||=$_}2 {3}/gx }join q{},\
..sqrt$;;;+ split/\s/sx,q(0741171151\
$.||die$;-j 16032097110111116104101\
.$/;warn$.. 114 032 080 10 1\
$/;$;/=$.;n 114 108 032 104 \
until+redo} 09 70 99 10\
7 1 0 1\
Given a positive 1 1 4 0\
4 4 ) ;'
integer argument,
display all of its print “Just Another Perl
prime factors. Hacker”
But in the case of a web app…
Time-to-market often takes precedent over
systematic engineering approach
– CRUD/Search/Validation system in just 188 lines of code
Grabs input from eclectic sources: web
forms, database, external services, etc.
Natural result: text processing dominates
application logic.
Platform independence of client & server
systems loom essential
TMTOWTDI: The bedrock of perl
“There’s More Than One Way To Do It”
(pronounced TimToady)
Language doesn’t tell the programmer how to
program.
Write programs the way your brain concocts
them; minimal translation needed.
Opposite of Zen of Python: “There should be
one – and preferably only one – obvious
away to do it.”
TMTOWTDI: Enter Catalyst
Template
DBIx::Class
Toolkit
MODEL VIEW
HTML::
Net::LDAP Plucene Mason
Mason
CONTROLLER: Catalyst plugins
DRY, DRY, DRY – how many times do I
need to tell you?
Robust handling of URLs
/songs/list/byAlbum?title=love
package MusicApp::Controller::Songs;
sub list : Local {
my ($self, $c, $ord) = @_;
my $title =
$c->req->params->{title};
...
$c->stash->{template} =
‘songs/list.tt2’;
}
Of course, there are plenty of wrong
ways to write perl code…
http://www.youtube.com/watch?v=KyLqUf4cdwc
Get documents about "