80 likes | 258 Views
Perl and Catalyst: The Chemistry Just Couldn’t be Any Better. Josh Poritz. Why do people complain about perl?. perl -e'map {map{print chr }/d {3}/gx }join q{}, split/s/sx,q(0741171151 16032097110111116104101 114 032 080 10 1
E N D
Perl and Catalyst: The Chemistry Just Couldn’t be Any Better. Josh Poritz
Why do people complain about perl? perl -e'map\ {map{print chr }/\d\ {3}/gx }join q{},\ split/\s/sx,q(0741171151\ 16032097110111116104101\ 114 032 080 10 1\ 114 108 032 104 \ 09 70 99 10\ 7 1 0 1\ 1 1 4 0\ 4 4 ) ;' $;=pop;{$.= 0;map{$;%$_ or$.||=$_}2 ..sqrt$;;;+ $.||die$;-j .$/;warn$.. $/;$;/=$.;n until+redo} Given a positive integer argument, display all of its prime factors. print “Just Another Perl 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 CONTROLLER: Catalyst plugins
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