Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


What is the difference between module and package?

Answers were Sorted based on User's Feedback



What is the difference between module and package?..

Answer / savitha sridhar

Modules and packages are usually used interchangeably. But
there is a difference.

a. Packages are perl files with .pm extn and is considered
a separate namespace. So a package is nothing but group of
related scalars,arrays,hashes and subroutines for a
specific purpose.Once a package is included in a .plx file
(using "use") and you want to call one of the subroutines
of the package, you may have to use the scope resolution
operator &package::subroutine1 ( as the subroutine of the
package is in a separate name space).

b. Modules are packages but which has the capabilities of
exporting selective subroutines/scalars/arrays/hashes of
the package to the namespace of the main package itself. So
for the interpreter these look as though the subroutines
are part of the main package itself and so there is no need
to use the scope resolution operator while calling them.

This is usually done like:

use Exporter;
our @ISA=('Exporter');
our @EXPORT=('$x','@arr',subroutine)

(you are exporting a scalar, array and a sub-routine from
the package). So if some .plx is using the above package
they need not use the scope resolution to call these.
A direct access like "print $x" would work even without
using the scope resolution.

Is This Answer Correct ?    22 Yes 8 No

What is the difference between module and package?..

Answer / kiruthikau

- A module is a .pm file containing some Perl code.
- A package is a declaration of the name of the current
scope, e.g.:
package Math::Complex
- Which can occur in the code of a module or a script.
- A module can be used, because it is a physical
'thing', but a package cannot.
- A module may contain several packages:

Is This Answer Correct ?    11 Yes 3 No

What is the difference between module and package?..

Answer / rameshravi

A package is a division of the global namespace; that means
you can have a global variable $foo and/or a sub named foo
in one package and a different global variable $foo and
different sub named foo in a different package.

A "module" is a file named according to the package it
contains, so module Foo::Bar would be in a file named
Foo/Bar.pm. There's no need for packages to be modules or
for a module to contain only that one package.

The term "module distribution" refers to a collection of one
or more modules that get built/installed together. Sometimes
the "distribution" part is left off and it's just called
"module", but it's really a different idea than a single module.

Is This Answer Correct ?    5 Yes 0 No

What is the difference between module and package?..

Answer / 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

More CGI Perl Interview Questions

Explain a tell function in perl?

0 Answers  


There is no strict data types in perl unlike in other high level languages like Java so wouldn't that be a problem if a code in perl is to be a written by a big team of 20+ members ?"

0 Answers   Cisco, Oracle,


Explain tk?

0 Answers  


What?s your favorite module and why?

3 Answers  


How can I implement the function overloading in Perl ? I read about the operator overloading, I do not know how to implement the function overloading. Thanks in advance ?

0 Answers  


What are the different instances used in cgi overhead?

0 Answers  


How to read a directory in perl?

0 Answers  


Which has the highest precedence, List or Terms? Explain?

0 Answers  


How can you create an object of a class in a package?

4 Answers   IBM,


What are the various advantages and disadvantages of perl?

0 Answers  


What are the advantages of programming in perl?

0 Answers  


Which functions in Perl allows you to include a module file or a module and what is the difference between them?

0 Answers  


Categories