in reply to OO Perl and Design Issues

One possibility is using another module from the POOP group Ovid mentioned earlier: SPOPS. Here's some sample code for you:

#!/usr/bin/perl use strict; use DBI; use SPOPS::Initialize; my ( $DB ); sub My::Sample::global_datasource_handle { unless ( $DB ) { $DB = DBI->connect( 'DBI:mysql:sample', 'me', 'pass' ) || die "Cannot connect: $DBI::errstr"; $DB->{RaiseError} = 1; } return $DB; } sub dump_objects { my ( $object_list ) = @_; foreach my $object ( @{ $object_list } ) { print <<DUMP; a: $object->{a} b: $object->{b} c: $object->{c} d: $object->{d} DUMP } } { my %config = ( sample => { class => 'My::Sample', isa => [ 'SPOPS::DBI::MySQL', 'SPOPS::DBI' ], field => [ 'a', 'b', 'c', 'd' ], id_field => 'a', base_table => 'sampletable', }, ); SPOPS::Initialize->process({ config => \%config }); # Create a new object and save it: my $new_object = My::Sample->new({ a => 15, b => 'Smithson', c => 0.389, d => 'Arf!' }); $new_object->save; # Grab an existing object and modify a field my $saved_object = My::Sample->fetch( 15 ); $saved_object->{d} = 'Quack!'; $saved_object->save; # Grab all the objects my $all_objects = My::Sample->fetch_group({ order => 'a' }); dump_objects( $all_objects ); # Grab some of the objects my $some_objects = My::Sample->fetch_group({where=>'b LIKE ?', value=>['smith%']}); dump_objects( $some_objects ); }

There are tons of other things you can do -- relating objects to one another, giving your object custom behaviors, setting rules so that you can ensure the data going into the database conforms to your business logic, just to name a couple -- but this gives you a brief idea.

Chris
M-x auto-bs-mode