This is how I think a lot of code probably looks. Although it should be in methods and stuff, here is at the very least how to do just the basics:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/perl
use strict;
use feature ":5.10";
use MyApp;
use MyApp::DB;
use JSON;
use Scalar::Andand;

my $schema = MyApp::DB->connect(@MyApp::DBConnectData);

#find a given shop
my $shop = $schema->resultset('Shop')->find(51311);
say $shop->ShopNo;
say $shop->OrderNo;
say $shop->AgentRequestedFirst;
say $shop->AgentRequestedLast;
say '';

#find all shops where the AgentRequestedLast starts with Dy
my $rs = $schema->resultset('Shop')->search({
        AgentRequestedLast => {'LIKE', 'Dy%'},
    },{
        rows => 10,
        order_by => ['AgentRequestedLast',
                    'AgentRequestedFirst', 'ShopNo DESC']
    });

# output pages 1, 3, and 6
foreach (1,3,6) {
    say '';
    say "Page: $_";
    my $paged = $rs->page($_);
    while (my $shop = $paged->next() ) {
        #Note: I added this method to my Shop class
        say $shop->as_string;
        # Note: Andand is awesome.  
        #Thanks groovy, raganwald, and Leon
        say $shop->ShopperDueDate->andand->day_name();
    }
}

# and to get some sweet, delicious JSON
$rs = $schema->resultset('Shop');
use DBIx::Class::ResultClass::HashRefInflator;
$rs = $rs->search({
        AgentRequestedLast => {'LIKE', 'Dy%'},
    },{
        rows => 10,
        order_by => ['AgentRequestedLast',
                  'AgentRequestedFirst', 'ShopNo DESC'],
        columns => [qw/AgentRequestedLast
                             AgentRequestedFirst ShopNo/]
    });
$rs->result_class('DBIx::Class::ResultClass::HashRefInflator');
my $data = {data=>[]};
while (my $shop = $rs->next() ) {
    push @{$data->{data}}, $shop;
}
say to_json($data);