Catalyst Improving your Catalyst Application #23

An example

sub action :Whatever {
    my ($self, $c) = @_;

    if($c->user_exists){
        my $data = $c->model('DBIC::Foo')->search({ foo => $c->req->params->{foo} });
        if($data->count > 42){
           $c->model('DBIC::FortyTwo')->create({ foos => $data->count });
        }
    }
    else {
        $c->model('DBIC::SixTimesNine')->create({ user => $c->user });
    }
}
Infinity Interactive