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!!