Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re^2: IP::Country::Fast library

by tsee (Curate)
on Mar 22, 2009 at 13:22 UTC ( #752385=note: print w/replies, xml ) Need Help??

in reply to Re: IP::Country::Fast library
in thread IP::Country::Fast library

Obviously, you found out the following already, but here it's for those reading along:

IP::Country::Fast puts its database files (aptly named with a .gif extension -- what the...?) into the lib/ hierarchy of the distribution. This has the result that they're installed into the normal Perl library paths along with the code.

Now, this is an inexplicably bad thing to do. You don't want arbitrary data cruft to reside in your library tree. But it gets worse. In order to *find* that file, the module goes on to access the place where IP::Country::Fast has been loaded from using $INC{"IP/Country/"}. This breaks in the PAR context (and always will) because the module *might not even have been loaded from a file*, but from memory after unzipping from the PAR archive!

There are several solutions to this. One would be to put the database (in base64 encoded form or similar) into the __DATA__ section of a real .pm file and simply load that and ask it for its *DATA file handle. This is what's done with PAR::StrippedPARL::* for example.

Another solution -- the elegant one -- is to NOT put that database in the lib/ hierarchy at all but to include it as a shared file. For details, check out the documentation of the excellent File::ShareDir module and specifically the section about using it for module-specific data. Now, to make this PAR-packaging friendly, you simply use the File::ShareDir::PAR wrapper of File::ShareDir instead which knows how to access such shared data files from PAR archives.

If all these solutions seem too difficult, then you should try to think about what makes them difficult. There is no good separation of code/logic and data where there should be a separation. CPAN distributions have never been very good at this and the File::ShareDir approach is an attempt to fix that. PAR is put in a much more problematic position again because it suddenly has to deal with that separation as well. It was devised mostly for dealing with logic.

To sum this up, this is a problem that requires an upstream solution. I very much doubt you can fix it in PAR/pp.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://752385]
[james28909]: another thing i am sick of is hurting others feelings
[1nickt]: james28909 You lost me a bit when you said "show me evolution from intelligence to ignorance". I guess we would have to define the terms, but as I look around at my species and how we are destroying our habitat ...
[james28909]: seems like a person cant even have a belief without hurting someones feelings. i never said my way is the only way. i just said i have pretty good scientific evidence, and then asked for opposing side to present evidence
[james28909]: was downvoted and left without a reply. go figure
[holli]: but then you DO give a fuck
[1nickt]: I don;t think beliefs should be down-voted, just behaviours.
[james28909]: im not quite how to explain it any better nick. you evolved from ignorance to intelligence. not the other way. the universe evolves from gas coulds and debris into planets stars and galaxies ect. it doesnt happen any other way. hence it has ....
[james28909]: some kind of logic behind it
[james28909]: and that is also anothe rpoint i made, i think it has to do with perception of the world around you. most people think of evolution on a human scale. why could life evolve on this planet? because this planet evolved in this solar system. and so on.
[holli]: here's something for you to watch, James. I think you will like it

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (13)
As of 2017-12-15 14:29 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (433 votes). Check out past polls.