Book Image

Catalyst 5.8: the Perl MVC Framework

By : Antano Solar John
Book Image

Catalyst 5.8: the Perl MVC Framework

By: Antano Solar John

Overview of this book

<p>Many web applications are implemented in a way that makes developing them difficult and repetitive. Catalyst is an open source Perl-based Model-View-Controller framework that aims to solve this problem by reorganizing your web application to design and implement it in a natural, maintainable, and testable manner, making web development fun, fast, and rewarding.<br /><br />This book teaches you how to use Catalyst to weave the various components involved in a web application, using methods and tools you personally prefer along with recommendations and details on the most popularly used objects like the DBIX ORM, TT2 Template, and Moose.<br /><br />This book will take you from how the MVC pattern simplifies creating quality applications to how Catalyst allows you to tap this power instantly. It explains advanced design patterns and concludes with the improvements that Moose brings to all this. It also incorporates valuable suggestions and feedback received from the community members and our customers. By the end of the book, you will be able to build clean, scalable, and extendable web applications. This book embodies Catalyst's philosophies of Do It Yourself and Don't Repeat Yourself.</p>
Table of Contents (16 chapters)
Catalyst 5.8
Credits
About the Author
About the Reviewer
Preface
7
Hot Web Topics
Index

Extracting the data


Now that our database is full of data, it's time to make some sense out of it. We'll start by writing a function to determine the total number of points a "thing" has accumulated.

Instead of writing a script to test each query we write, we'll use a read-evaluate-print loop (REPL) to interact with our program in real time. To get a Perl REPL, install the Devel::REPL module from CPAN. That module provides a script called re.pl. Run re.pl, and you'll be able to type in Perl code as though you're at a shell prompt that understands Perl.

As an example, let us try adding an opinion from re.pl:

$ re.pl # the > is now re.pl's prompt
> use lib qw(lib);
> use ChatStat::Action;
> use ChatStat::Schema;
> my $s = ChatStat::Schema->connect('DBI:SQLite:root/database');
$ChatStat_Schema1 = ChatStat::Schema=HASH(0x8aafda0);
> my $a = ChatStat::Action->new('[email protected]', '#test', '(re. pl)++');
$ChatStat_Action1 = ChatStat::Action=HASH(0x90dbe40);
> $a-&gt...