I have perl script which contains all functions. Now how can i call these functions from another script. Do i need to install the first script as a package. If so can anyone tell me how i can do it.
To memory, haven't looked at it in a while, if you put a 1 at the end of the (2 B included) file, and require the file, the functions and variables should be accessible.
The package idea is proabably well worthwhile looking at
How to install the package you have constructed ?
The better way when constructing a new package is to use h2xs tool, because it creates the schelet for you. It also create a Makefile.PL template script, which you can use to install the package.
Let say you want to construct a package called my_package.
From the shell (or command promp) issue the following:
%>h2xs -AXn my_package
This will create a directory called my_package. Inside it will create the following files:
Edit the my_package.pm file, to your package. Follow comments inside the package. Edit the Makefile.PL file as you need.
From the command prompt issue:
%> perl Makefile.PL
A makefile will be generated for your platform.
NOW HOW TO INSTALL THE PACKAGE?
Like any package from CPAN
make
make test
make install
Now you really have installed the package. From now, you do not have to worry about the path to the package file, when using the package from your scripts.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.