CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
module specific property file

 



handreach
New User

Apr 2, 2009, 12:51 AM

Post #1 of 3 (1448 views)
module specific property file Can't Post

Dear Perl guru,

I have a Perl module that relies on a specific property file to initialize. The thing that has been bothering me is what the best practice is to put such property file. The option that I prefer is to put the property file in the same folder of the Perl module for easy packaging, but I don't know how to make the module locate the path of itself to read the property file. It's easy to get the current working path of the main program, but not trivial to get the path of an individual module in the main program. One could use the PERL5LIB environmental variable to scan and locate the path of the target module, but what if the module was called using the "use lib" style by the main program? Another option that I can think of is to use the __DATA__ virtual file to physically append the property file at the end of the Perl module. But, I am not sure whether it's the best practice and whether there is any better choice. I'd appreciate if you give me any advice. Thanks!


(This post was edited by handreach on Apr 2, 2009, 12:54 AM)


1arryb
User

Apr 2, 2009, 12:26 PM

Post #2 of 3 (1433 views)
Re: [handreach] module specific property file [In reply to] Can't Post

Hi handreach,

You could turn your property file into it's own (simple) module, then 'use' or 'require' it. The loader will find it then, as long as it's in the Perl libpath.

This might be preferable to an external properties file anyway, as such a thing implies that the properties are open to change by the user.

Larry


handreach
New User

Apr 2, 2009, 9:41 PM

Post #3 of 3 (1408 views)
Re: [1arryb] module specific property file [In reply to] Can't Post

That sounds a good idea. Thank you!

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives