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

Re: How to distribute an example data file in a CPAN module

by jplindstrom (Monsignor)
on Feb 20, 2009 at 00:58 UTC ( #745244=note: print w/replies, xml ) Need Help??


in reply to How to distribute an example data file in a CPAN module

I think SQLite db files are binary cross platform, but possibly not across versions. I guess you'd have to check the SQLite manual for that.

That does sound a bit fragile in any case, so the DDL might be a more solid choice.

You can put data files next to where your module source gets installed. Find out where that is:

package Your::Module; use Path::Class; # Return ".../site_lib/Your/Module/data/sample.sql" sub sample_db_file { file( file(__FILE__)->dir->absolute, "data", "sample.sql") . ""; }

If you use Module::Build, you need to specify that nonstandard file extensions should be packaged, like this:

# Build.PL $builder->add_build_element('sql');

Not sure about the EMM or Module::Install incantations.

So you'll need to create a .db file in a convenient (for the user) writable location. File::HomeDir might be useful for finding that location.

/J

Replies are listed 'Best First'.
Re^2: How to distribute an example data file in a CPAN module
by zby (Vicar) on Feb 20, 2009 at 07:08 UTC
    Thanks! Although I decided to put the SQL into __DATA__ - but once it grows I'll remember your solution :)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://745244]
help
Chatterbox?
[perldigious]: Quick question, is undef %hash a recommended/good way to delete an entire hash structure from memory? Or sould I be doing it some other way?
[1nickt]: The best way is to scope it tightly so it just goes away when you are finished with it.
[perldigious]: but... but... perldigious is the unvirtuous kind of lazy in this case. :-)
[perldigious]: Just kidding. Thanks 1nickt, I'll go ahead and do it the right way. An extra set of brackets and a little extra indentation isn't too much to ask.

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (9)
As of 2017-07-21 19:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (335 votes). Check out past polls.