package MyDB; use base 'Class::DBI'; __PACKAGE__->set_db('Main', 'dbi:mysql:mydb', &db_login_credentials); sub db_login_credentials { my $group = &who_is_this; if ($group eq 'staff') { return ('staff', 'password'); } elsif ($group eq 'public') { return ('public', 'password'); } else { die 'who is this person?'; } } sub who_is_this { # do whatever it takles to figure out if it's public or # staff, and return either 'staff' or 'public'; } if (&who_is_this eq 'public') { __PACKAGE__->add_trigger(before_create => sub { die 'not authorized to create'; }); __PACKAGE__->add_trigger(before_update => sub { die 'not authorized to update'; }); __PACKAGE__->add_trigger(before_delete => sub { die 'not authorized to delete'; }); }