Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Data files included in a package

by bart (Canon)
on Aug 29, 2003 at 01:11 UTC ( [id://287563]=note: print w/replies, xml ) Need Help??


in reply to Data files included in a package

Well, yes, a subdirectory of the library's own subdirectory looks OK to me. But maybe that's just me. Actually, any place where that package could reside in @INC is fine by me, but don't expect any help from perl to locate it from you. You'll have to emulate what perl does in require, scanning through @INC and seeing if the data files can be found. Or you could demand that the data files have a fixed relative position toward the location of the module file itself. You decide.

But don't take my word for it. Take a look at a well-established module from CPAN: XML::Parser. Just look at the character encoding files ("*.enc") that XML::Parser::Expat, the underlying parser engine, uses, and how it locates them in @INC — source of XML/Parser/Expat.pm, populating @Encoding_Path.

Addendum.

is there a method for determining the path to the package?
Take a look at %INC. If your module is Foo::Bar then it'll be under $INC{"Foo/Bar.pm"}, even on systems where the file path separator isn't a slash, like Windows (actually a backslash, though a slash works too) and the Apple Macintosh, where it is ":" (!).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://287563]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2024-04-19 02:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found