http://www.perlmonks.org?node_id=140055


in reply to Refactor method calls or not?

You could also create and install these in the package by assigning closures to typeglobs.
sub create_add_to_table { my $table = shift; sub { my ( $self, $data ) = @_; my $data = $self->_generic_insert( $data, $table ); $self->{ _dbh }->commit if ! $self->{ _error }; return $data; }; } *add_company = create_add_to_table('company'); *add_financial_diary = create_add_to_table("financialDiary");