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

What is the use of "stderr()"?

956


What is goto statement in perl?

888


What is warn function in perl?

886


Comment on data types and variables in perl.

873


Why to use perl?

884


What is “grep” function in perl?

939


how to get back up from private character editor which is saved in the format of .udf

2241


What is 'rollback' command in perl?

900


How will you create a file in perl?

914


What rules must be followed by modules in perl.

946


Write an example explaining the use of symbol tables.

898


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

847


What is perl pop array function?

880


what are the strategies followed for multiple form interaction in cgi programs?

879


What is cpan ? What are the modules coming under this?

867