Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

List of functions, variables export by Perl module.

Status
Not open for further replies.

1yura1

Programmer
Feb 7, 2003
36
UA
Hi All.

How can I get list of functions, which are export by Perl module used by script.

For example:
I have [Addon.pm] module.
It exports next list of functins:
---------------------------------
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK );

$VERSION = 0.1;
@ISA = ('Exporter');
@EXPORT = qw(
&function_1 &function_2
&function_n
);
@EXPORT_OK = qw(
);
---------------------------------
How can I from Perl script get thi list of functions (function_1, function_2, ... , function_n)?
 
A quick way is something like:
Code:
for (@Addon::EXPORT) {
  print "$_\n";
}
This will give you a list of all exported object, not just functions.

There is likely a better way ( *waits for missbarbell to show how little he knows* ;-) )
 
for (@Addon::EXPORT) {
print "$_\n";
}

It does not work :(
 
Do you get any error or did nothing print? You should be able to read from any Expoter derived module this way (once you've use'd it of course).
 
#!/usr/bin/perl
use VServer::Addon;
for (@Addon::EXPORT) {
print "$_\n";
}

Prints nothing
 
If your module is named VServer::Addon then your for loop should be:
Code:
for (@VServer::Addon::EXPORT) {
  print "$_\n";
}
Whatever the package name is needs to be prepended to the EXPORT array.

Hope that helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top