?
Solved

Module config file

Posted on 1999-12-25
6
Medium Priority
?
160 Views
Last Modified: 2013-11-18
I am creating a module and I want some user settings to reside in a text file, which would live in the same directory as the module (.../site_perl/...). What is the easiest way to open the file from the module? I know I could try all the entries in the @INC array, but wondered if there is a siimpler approach.
0
Comment
Question by:Kim Ryan
  • 3
  • 3
6 Comments
 
LVL 85

Expert Comment

by:ozo
ID: 2306394
use myconfig; #will automatically try all the entries in the @INC array for you
0
 
LVL 19

Author Comment

by:Kim Ryan
ID: 2306919
Is myconfig a module I need to install? I can't seem to find any refernece to it.
0
 
LVL 85

Expert Comment

by:ozo
ID: 2306965
"myconfig" was an example for the name of your user setting file which would live in the same directory as the module.
0
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

 
LVL 19

Author Comment

by:Kim Ryan
ID: 2307163
Does this mean that I create a file called myconfig.pm and have it return a 1 (ie normal rules foe use statement?) I want my users to maintain a simple text file.
0
 
LVL 85

Accepted Solution

by:
ozo earned 400 total points
ID: 2307223
use FindBin qw($Bin);
print "$Bin - path to bin directory from where script was invoked";

use $myconfig; #the filename you specified
print $INC{"$myconfig.pm"}; #the location of the file actually found
0
 
LVL 19

Author Comment

by:Kim Ryan
ID: 2307425
Thanks ozo, I can see that this works. As this is for a CPAN module (Lingua::EN::NameParse-1.00) I don't want the user to have more  modules installed than necessary. I will loop over the @INC array anyway as it is fairly simple to do.
0

Featured Post

[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

Question has a verified solution.

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

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

599 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