http://qs321.pair.com?node_id=498374


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)