I use the same technique - in my case it is for a database abstraction layer, where each file/subroutine describes a db access method, like this:
package DBAccess;
use strict;
use Sybase::CTlib;
sub addMaillog {
my $self = shift;
my %args = @_;
my $config = { name => 'addMaillog',
param => {
token => { type => CS_CHAR_TYPE,
opt => 0},
email => { type => CS_CHAR_TYPE,
opt => 0},
action => { type => CS_CHAR_TYPE,
opt => 0},
},
output => [ {
name => 'maillog',
cols => [qw(maillogId)],
}],
server => 'main',
database => 'rpc',
};
$self->execute($config, \%args);
}
1;
Each file only has this description, and everything else is handled by the rest of the package.
It makes adding/modifying database requests very easy, though the fact that they are all stored procedure calls simplyfies things as well. There are no doubt other ways to do this, but it works fine for me at the moment.
Note that this is based on Sybase::CTlib, but it could very well be built using DBI/DBD::Sybase as well.
Michael |