Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: modules as data files

by ioannis (Abbot)
on Oct 08, 2005 at 06:51 UTC ( #498374=note: print w/replies, xml ) Need Help??


in reply to modules as data files

There is little difficulty, if you first think for the simple solution: call it with do() from ::main, and fetch as the return value the hash itself. At least the do() statement will in fact fetch something each and every time it is called, but require() will only fetch it once only
####### Inside "test0.pm" ############################### return $data = { k0 => 'apple' , k1 => 'orange', }; ###### Inside the main program: ############################### use strict; use warnings; my $pmfile = shift @ARGV; my $pm = do "$pmfile" or die

Replies are listed 'Best First'.
Re^2: modules as data files
by Anonymous Monk on Oct 10, 2005 at 19:02 UTC
    well, just kick me! i had a feeling the answer was embarassingly straightforward

    your answer of having the module return the hash solves both problems of :

    - knowing the package name

    - knowing the hash name

    thanks although i'm _really_ embarrassed! ( sorry to bother ya'll)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2022-11-30 20:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?