What is the difference between module and package?

Answer Posted / shankarreddy k

A module is basically a set of subroutines that are
designed to do a specific set of tasks, all with a common
goal/topic. You "use" modules in your Perl code and once
you do, their functions are available to you.

Now, say you have two modules that end up having two
functions with the same name, but do two completely
different things. You need to be able to tell them apart.
That is where the module, acts like a namespace.

For example, if modules "My::First::Module"
and "My::Second::Module" both have a function called "Count
()", but you need the version from "My::First::Module",
then you would specify that when you called the function,
like so:

My::First::Module::Count(options)
{
some code;
}

Ok, that is my take on this topic. Short and sweet.
Hopefully, if there is more, and I am sure there is, that
someone will enlighten not only you, but me as well.

Regards,
shankar

Is This Answer Correct ?    4 Yes 7 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is epoch time in perl?

521


How to add elements in a hash in perl?

510


What is perl? What is the basic command to print a string in perl?

480


What is the importance of perl warnings?

533


Define print() function in perl?

553






What is automatic error handling in perl?

495


What is “grep” function in perl?

560


Explain the internal working of cgi

505


What syntax is used for grep() function?

569


Create a function that is only available inside the scope where it is defined ?

549


What is the use of '>>' in perl?

539


What are the different instances used in cgi overhead?

574


How do you you check the return code of a command in perl?

579


How will you open a file in a write-only mode in perl?

476


How many types of primary data structures in Perl and what do they mean?

845