#! /usr/bin/env perl use strict; use warnings; use 5.020; package DB::Base { sub new { my $class = shift; my $self = { table => shift, }; bless $self, ref($class)||$class; return $self; } # general methods sub foo { my $self = shift; printf "%s: foo\n", ref($self); } sub bar { my $self = shift; printf "%s: bar\n", ref($self); } sub show_table { my $self = shift; printf "%s: %s\n", ref($self), $self->{table}; } }; package DB::Service { use base "DB::Base"; # define methods for service actions }; package DB::Customer { use base "DB::Base"; # define methods for customer actions }; package main; # provide table information as argument my $customer = DB::Customer->new('customer'); $customer->show_table(); # provide table information as argument my $service = DB::Service->new('service'); $service->show_table(); __END__;