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?

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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How many types of operators are used in the Perl?

1074


Explain goto label, goto name, and goto expr?

972


What is the easiest way to download the contents of a URL with Perl?

995


Explain '->' in perl?

974


In Perl we can show the warnings using some options in order to reduce or avoid the errors. What are that options?

1050


Explain join function in perl?

1001


you are required to replace a char in a string and store the number of replacements. How would you do that?

979


What are the functions that can be performed using cgi program?

975


What are some common methods to all handles in perl?

976


What is the closure in PERL?

1068


How to read a single line from a file in perl?

1013


What is perl unshift array function?

1116


You want to download the contents of a url with perl. How would you do that?

928


What is the difference between use and require in perl programming?

986


What rules must be followed by modules in perl.

1040