Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help in converting procedural codes into OOP

Status
Not open for further replies.

whn

Programmer
Oct 14, 2007
265
0
0
US


I am new to oop in perl and I need help in converting some procedural codes into OOP.

For instance, I have a perl module which was implemented in a procedural style:

Code:
package my_module;

sub get_a_list {
  my %list;
  # some implementation here
  return \%list;
}

And another perl code calls my_module.pm:

Code:
use my_module;

my $list = &my_module::get_a_list();

Now, I want to re-implement my_module.pm in an OOP manner so that I can call my_module::get_a_list() somewhat like below:

Code:
use my_module;

my $obj = my_module->new();
my $list = $obj->get_a_list();

But I don’t know how to modify my_module.pm to make it happen. Could someone kindly show me the sample codes?

Many thanks!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top