Solved

Problem with .pm file

Posted on 2014-02-18
1
232 Views
Last Modified: 2014-02-18
Is there a way to have a perl script find a .pm file, when you don't have access to the directories that @INC includes? (Other than ".")

I have created a script that loads a .pm file that contains all sorts of variables. I do not presently have access to any of the directories that perl looks into in it's @INC list, with the exception of ".". I change directories while running the script, and run other scripts, that also load the same .pm file. When I run the main script, from the directory that contains the .pm file in question, it runs fine, while the other sub-scripts die, because they can not find the .pm file.

Is it possible to load a .pm file with an absolute path? Or, does one have to always be able to load the .pm into a directory that @INC includes? Or can one define @INC for the user, in their log in script?

I have already modified the user's path to include the directory that has the scripts. I am not sure how to tell perl to modify @INC, as a non-admin user...
0
Comment
Question by:stakor
1 Comment
 
LVL 28

Accepted Solution

by:
FishMonger earned 500 total points
ID: 39867462
You can use the lib pragma to add a path to the @INC array.

For example, lets say the full path to your module is: /home/stakor/lib (your module is in that directory).  The lib statement in your scripts would be:
use lib '/home/stakor/lib';
use YourModule;  # load your module

Open in new window

You can also use the local::lib pragma to accomplish the same thing.

The lib pragma is part of the perl core, so it will be available for you to use.  The local::lib pragma is not part of the core, so it may or may not already be installed.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now