##################### Package Person sub new { my $proto = shift; my $class = ref($proto) || $proto; my $self = {}; $self->{FETCH} = Fetch->new(); $self->{ADD} = Add->new(); bless ($self, $class); return $self; } sub fetch { my $self = shift; return $self->{FETCH}; } sub add { my $self = shift; return $self->{ADD}; } 1; ##################### and the underlying classes will look like so.. ##################### Package Fetch sub new { my $proto = shift; my $class = ref($proto) || $proto; my $self = {}; $self->{FIELDS} = []; $self->{FILTERS} = {}; $self->{RECORD_COUNT} = 0; $self->{RECORD} = []; $self->{DB_TYPE} = 'oracle'; $dbh = connect_db( 'login', 'password', 'dsn' ); bless ($self, $class); return $self; } sub fields { ..... } sub fetch_records { ..... } ##################### and the usage of the package is as follows ##################### use Person; $per = new Person(); $fch = $per->fetch(); # Set Fields $fch->fields( 'first_name', 'last_name', 'middle_name' ); # Get Fields print "The fileds being fetched are " . $fch->fields . "\n"; # Fetch People. while( (@prsn) = @{$fch->fetch_records()} ) { print "@prsn\n"; } print "No. of persons fetched are " . $fch->record_count(); #####################