The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 02-01-2008
KevinADC KevinADC is offline
Registered User
 

Join Date: Jan 2008
Posts: 338
You can use the "lib" pragma to use modules in your perl script. I just expalined how to do this on another forum, let me copy and paste that reply here....


If it is not a module with lots of dependencies (although you can still do it this way if it is) you use the "lib" pragma to include your own module directories into perls @INC array. Say you have a module named Foo::Bar.

Foo is the directory the module is stored in and the module is named Bar.pm. You can create a Foo directory in any folder on your website, but best to use one that is not www accessible. People often name it mymodules or cpanmodules. In that folder you duplicate the modules structure, so you create a folder named Foo in mymodules folder and place Bar.pm in the Foo folder. Then in your perl script:

use lib qw(path/to/mymodules);
use Foo::Bar;
Reply With Quote