What's the significance of @ISA, @EXPORT @EXPORT_OK %EXPORT_TAGS list & hashes in a perl package? With example?

Questions by geek_zubi   answers by geek_zubi

Showing Answers 1 - 3 of 3 Answers

Nitien

  • Mar 8th, 2006
 

@ISA ->  each package has its own @ISA array. this array keep track of classes it is inheriting.

ex:

package child;

@ISA=( parentclass);

@EXPORT this array stores the subroutins to be exported from a module.

@EXPORT_OK this array stores the subroutins to be exported only on request.

  Was this answer useful?  Yes

terrytlin

  • Dec 3rd, 2009
 

Package NewModule;
use Exporter; # an application by ‘use’ operator.#
This Exporter package has @ISA array to look for a specific method, this array keeps track of classes it is inheriting.
@ISA=qw(Exporter);
@EXPORT=qw(VAR1 VAR2 VAR3);
# The symbols VAR1, VAR2, VAR3 loaded by default
@EXPORT_OK qw(VAR4 VAR5);    
# the symbols VAR4 and VAR5 only loaded if there is a request.

  Was this answer useful?  Yes

Jatin

  • Jan 5th, 2013
 

%EXPORT_TAGS = (tag_name => [anonymous array/Array reference]);
It is to provide the tag to Anonymous array/Array reference which is generally @EXPORT_OK

for example:
%EXPORT_TAGS = (all => @EXPORT_OK]);

At the time of loading use simply

use Bar qw/all/ # instead of writing all the symbols

Cheers.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.